2

How to scroll page using webdriver directly. I know how to scroll using javascript executor. My question is, can it be done without using java script??

With java script I was using following:

JavascriptExecutor jsx = (JavascriptExecutor)driver;
jsx.executeScript("window.scrollBy(0,450)", "");
MHH
  • 95
  • 5

1 Answers1

3

If you want to scroll to end of the page, you can do following:

Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();
//OR
actions.sendKeys(Keys.chord(Keys.CONTROL, Keys.END)).perform();

If you want to scroll bit by bit, you can do following:

Actions actions = new Actions(driver);
actions.sendKeys(Keys.SPACE).sendKeys(Keys.SPACE).sendKeys(Keys.SPACE).perform();

However if you want to scroll to a specific point on page, Java Script is your best bet.

Husam
  • 1,095
  • 11
  • 16