I’m working con SeleniumLibrary in a web where a need to go to a locator that is out of the current view. In the “real life” I use the mouse wheel to go down in the screen.
I’m trying to use the “Scroll element into view” but I get an error because the element is out of the bounds of the viewport.
Does anyone know how I “simulate” the scroll down of the mouse wheel or do something similar to move the screen to the desired locator?
Your suggestion works fine. My problem is using that I scroll all the page but I need to scroll an small area inside the page. How can I scroll only that sub-window?
I have already run over a similar problem recently. I noticed a potencial problem with the SeleniunLibrary when you need to reach a element that requires mouse scroll up or down using the keywords Click Button, Click Element, Scroll Element Into View.
I noticed that:
The mentioned keywords can find the element
The screen is scrolled to the element automatically
We can see the element highlighted (in some cases)
But the SeleniumLibrary keyword fail
Workaround directly over Robot Framework
I created my own version of Click Button, Click Element, Scroll Element Into View with retries. When the element is out of the screen, you will noticed that in the first execution the original keyword will fail, but it will work in the second attempt.
Click Button Ex
[Arguments] ${xpath} ${attempts}=4
${status} Set Variable ${False}
WHILE ${status} == ${False}
${status} Run Keyword and Return Status Click Button ${xpath}
${attempts} Evaluate ${attempts} - 1
Run Keyword If ${attempts} == 0 Fail ${xpath} not found
END
Also, regarding to that other problem:
I also run over a similar problem in my current project until I noticed that the “sub-windows” was inside a “iframe”. So I use the following keywords to change the context page (after spend a lot of time on that ) :