当前位置 : 主页 > 网络安全 > 测试自动化 >

如何在Selenium IDE中自动化鼠标滚动事件

来源:互联网 收集:自由互联 发布时间:2021-06-19
我试图在selenium IDE中捕获/自动化鼠标滚动事件. 就像在Facebook好友列表页面中一样,我们必须滚动到最后列出所有朋友. 我想使用Selenium IDE自动化该功能. 我做了什么 : with my current scrip
我试图在selenium IDE中捕获/自动化鼠标滚动事件.
就像在Facebook好友列表页面中一样,我们必须滚动到最后列出所有朋友.

我想使用Selenium IDE自动化该功能.

我做了什么 :

  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.

我无法做到的

  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.

Selenium RC:

selenium.getEval( “window.scrollBy(X,Y)”);

Selenium IDE:

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

更新:

<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>

这会将窗口滚动到3个不同的坐标.

网友评论