7Gabriel / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 0 forks source link

how to scroll down till element is visible #133

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Operating system :
.Net Framework version :
Office Version :
SeleniumWrapper version :

What is your issue ?

There are 5 elements/links in a page which should be clicked(clicking on each 
link opens a modal) and 2 or 3 links are displayed on page load and for other 
links page need to be scrolled down. 
.click is working for first 2 links but for the 3rd link page is scrolled down 
a bit but the class of the 3rd item overlaps with the feedback class and code 
fails. Is there a way to scroll the page till the element is clearly visible. 
Does driver.focus help in this situation? If so, please share the syntax of 
driver.focus

Original issue reported on code.google.com by santhosh...@gmail.com on 30 Jan 2015 at 8:00

GoogleCodeExporter commented 8 years ago
You can try to go to the end of the page by using the keys:
driver.sendKeys Keys.END

Or you could use some JavaScript:
driver.executeScript "window.scrollBy(200,0)"

Original comment by florentbr on 4 Feb 2015 at 2:21

GoogleCodeExporter commented 8 years ago
Thanks florentbr. Apologies for not updating the thread, I got the solution 
while browsing other sites.
driver.executeScript "window.scrollBy(0, 150);" has worked for me

sendkeys Keys.END did not work and even if it works, the content i am trying to 
click might not be at the end of the page.

Original comment by santhosh...@gmail.com on 4 Feb 2015 at 7:37