Scroll page up or down with selenium in java

  • 1 Replies
  • 983 Views
Scroll page up or down with selenium in java
« on: April 27, 2016, 14:30:54 pm »
Whats the easiest way to make the browser scroll down (or up) by a small margin ?

*

Oren

  • **
  • 59
Re: Scroll page up or down with selenium in java
« Reply #1 on: May 30, 2016, 23:23:09 pm »
Try using JavaScriptExecuter:

Code
WebDriver driver = new FirefoxDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollBy(0,200)", "");

for scrolling down use a negative value e.g. -200 :)

 

Sitemap 1 2 3 4 5 6 7 8