How to automate mouse scroll event in Selenium IDE

I am trying to capture / automate a mouse scroll event in a Selenium IDE. Like the Facebook friend list page, we need to scroll to the end to list all the friends.

I want to automate this functionality with the Selenium IDE.

What I've done:

  • with my current script, I can log in to Facebook.

  • Then, by clicking on my name from the title, I can go to my profile page.

  • On my profile page, I save the value of the number of friends, and then by clicking the friends link, I can go to the friends list page.

  • On the friend list page, using the assert function, I compare the value of the number of friends that I saved on the previous page with the number showing on the friend list page.

What i can't do

  • I want to scroll with the command and compare how many friends are already listed and how many are left,

if (<1 left), then I will not scroll further

else, I will scroll through a certain amount of time and again compare the amount remaining.

+6
source share
1 answer

Selenium RC:

selenium.getEval("window.scrollBy(x,y)");

Selenium IDE:

 storeEval | selenium.browserbot.getCurrentWindow().scrollTo(x,y) 

UPDATED:

 <tr> <td>storeEval</td> <td>selenium.browserbot.getCurrentWindow().scrollTo(100,800)</td> <td></td> </tr> <tr> <td>waitForPageToLoad</td> <td></td> <td>10000</td> </tr> <tr> <td>storeEval</td> <td>selenium.browserbot.getCurrentWindow().scrollTo(200,1600)</td> <td></td> </tr> <tr> <td>waitForPageToLoad</td> <td></td> <td>10000</td> </tr> <tr> <td>storeEval</td> <td>selenium.browserbot.getCurrentWindow().scrollTo(300,2400)</td> <td></td> </tr> 

This will scroll the window to three different coordinates.

+4
source

All Articles