TestProject Forum
Powered by leading experts in the test automation community

Scroll page up or down with selenium in java

Whats the easiest way to make the browser scroll down (or up) by a small margin ?

Try using JavaScriptExecuter:

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

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