Skip to content

Instantly share code, notes, and snippets.

@santhoshv339
Created January 23, 2017 12:28
Show Gist options
  • Save santhoshv339/9b92fadd2879a5d14b548e72cd5b5083 to your computer and use it in GitHub Desktop.
Save santhoshv339/9b92fadd2879a5d14b548e72cd5b5083 to your computer and use it in GitHub Desktop.
Scroll by given pixel Offset
//To scroll down web page by 900 pixels In x(vertical) direction.
//You can y parameter to scroll page In horizontal direction.
JavascriptExecutor javascript = (JavascriptExecutor) driver; javascript.executeScript("window.scrollBy(0,900)", "");
//To scroll up web page by 300 pixels In x(vertical) direction.
javascript.executeScript("window.scrollBy(0,-300)", "");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment