Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ValchanOficial/96e73fc1118abeb457ad2954b790a90f to your computer and use it in GitHub Desktop.
Save ValchanOficial/96e73fc1118abeb457ad2954b790a90f to your computer and use it in GitHub Desktop.
Scroll UP or Down a page in Selenium Webdriver
https://www.guru99.com/scroll-up-down-selenium-webdriver.html#2
https://stackoverflow.com/questions/12293158/page-scroll-up-or-down-in-selenium-webdriver-selenium-2-using-java
For Scroll down:
WebDriver driver = new FirefoxDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollBy(0,250)", "");
OR, you can do as follows:
jse.executeScript("scroll(0, 250);");
For Scroll up:
jse.executeScript("window.scrollBy(0,-250)", "");
OR,
jse.executeScript("scroll(0, -250);");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment