Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
660 views
in Technique[技术] by (71.8m points)

javascript - Unable to scroll down the web page using the Robot Framework

I am using Selenium 2 and Robot Framework to automate our application. I have used the below JavaScript code to scroll down the page but am not able to scroll.

I want to enter text inside the text box after scrolling down, but I am receiving the exception:

Element not visible

The text box is partially visible on the screen by default, if we manually scroll down than its completely visible, But selenium robot framework unable to scroll down.

I have tried:

Execute JavaScript    window.scrollTo(0,200)

Execute JavaScript    window.scrollBy(0,200)

Execute JavaScript    window.scrollTo(0, document.body.scrollHeight)

How can I fix this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your scrolling code looks ok. However, I don't think scrolling is your problem. Element visibility is ok even if it is scrolled away from screen. Try this code for example. At least on Chrome page scrolls back up at Input Text keyword

*** Settings ***
Library         Selenium2Library

*** Test Cases ***
Scroll
    Open Browser   http://www.stackoverflow.com/    Chrome
    Execute JavaScript    window.scrollTo(0, document.body.scrollHeight)
    Input Text    //*[@id="search"]/input    robot framework
    Sleep    3
    Close All Browsers

I think you may have an incorrect locator for your edit box.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...