How to Automate Mouse scrolling event in Selenium IDE

女生的网名这么多〃 提交于 2019-11-30 14:14:11

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/13488359/how-to-automate-mouse-scrolling-event-in-selenium-ide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!