6

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

I want to automate that functionality using Selenium IDE .

What i have done :

  1. with my current script i can log in to Facebook.

  2. Then on clicking on my name from the header i can go to my profile page.

  3. At my profile page, i am storing the value of number of friends, and then on clicking the friends link i can go to the friend list page.

  4. At friends list page using assert function i compare the value of number friends which i stored at previous page with the number showing at the friend list page.

What i am not able to do

  1. I want to scroll using command and compare howmany friend are already listed and how much is remaining ,

if (remaining <1) then i will not scroll further

else i will scroll for some amount of time and again compare how much is left.

shas
  • 703
  • 2
  • 8
  • 31
John
  • 700
  • 3
  • 17
  • 30

1 Answers1

4

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 3 different coordinates.

Abhishek_Mishra
  • 4,551
  • 4
  • 25
  • 38
  • Hi abhi can u please tell me " scrollTo(100,800)" that 100,800 are parameter of what ? – John Nov 21 '12 at 07:44
  • I used the code u suggested for selenium ide but automatic scrolling is not happening , can u tell me how i will get the x,y values. – John Nov 21 '12 at 07:56
  • Dear are u increasing the coordinates value time by time?If you will keep the value hard coded than it will scroll just once.You better use some loop kind of thing and execute this command in the loop by incrementing coordinate value.In case of IDE you have to write the command multiple times with different values. – Abhishek_Mishra Nov 21 '12 at 08:05
  • Hi abhi i have used that parameter value hard coded [500,800] , may be that why it was not scrolling properly. Can you tell me how can i capture the x,y coordinate values dynamically. i think if i able to capture that value dynamically then using loop and compare i can scroll upto bottom of the list. – John Nov 21 '12 at 08:15
  • 1
    For an elment you can get the coordinates using storeElementPositionLeft and storeElementPositionTop commands.I have also made an update to my answer with hard coded values.Hope that will be useful to u. – Abhishek_Mishra Nov 21 '12 at 08:27