Web Page Scroll Selenium WebDriver Example

One of the frequently appearing scenarios in test automation activities is scrolling a web page. We can simulate this scroll behavior in Selenium WebDriver by using scrollBy JavaScript method. Follow below steps to implement scroll Selenium WebDriver scenario.

We will use JavaScriptExecutor method to execute JavaScript in Selenium WebDriver. JavaScript method for web page scrolling is scrollBy. Below is a simple code to scroll down the page using this method.

You will need to import Selenium JavaScriptExecutor package in your Java class. You can use (-50, 0) parameter to scroll up the web page.

Leave a Reply

Your email address will not be published.