SELENIUM BASICS:


SELENIUM WEBDRIVER:


TESTNG:


REPORTS:


BUILD & CONTINUOUS INTEGRATION TOOLS:


CROSS BROWSER TESTING:


MOBILE TESTING:


AUTOMATION FRAMEWORKS:


API Testing:


INTERVIEW QUESTIONS:


SAMPLE RESUME:

How To Scroll Web Page Down Or UP Using Selenium WebDriver

Let’s see how to Scroll Web Page DOWN or UP in this post. There are few ways to scroll Web page up or down using Selenum WebDriver. We are going to see those in this post in detail.

JavaScript scrollBy() method scrolls the document by the specified number of pixels.

Also Read: How To Use JavaScriptExecutor in Selenium

Syntax:

window.scrollBy(xnum, ynum)

Parameters:

  • xnum is a Number
  • Required. How many pixels to scroll by, along the x-axis (horizontal). Positive values will scroll to the right, while negative values will scroll to the left
  • ynum is a Number
  • Required. How many pixels to scroll by, along the y-axis (vertical). Positive values will scroll down, while negative values scroll up

Return Value:

No return value

To Scroll Web page Down using Selenium WebDriver:

In the below example we use 250 pixels for vertical scrolling in order to see how scroll method works

To scroll to the Bottom of the Web Page using Selenium WebDriver:

We get the height of the Body element from the DOM (Document Object Model) and we use the scrollTo() method to scroll to the maximum height of the page:

To Scroll Web page Up using Sleneium WebDriver:

Just modify the pixels value to negative number and pass as the second parameter of the scrollBy() method.

If you are not a regular reader of my blog then I highly recommend you to signup for the free email newsletter using the below link.

Get our latest blog posts delivered to your inbox

Subscribe and get popular blog posts about software testing industry.

Rajkumar

1 thought on “How To Scroll Web Page Down Or UP Using Selenium WebDriver”

  1. Very Thank you !! It is very helpful.But now my query is How can we scroll down webpage using web driver sampler in jmeter.

Leave a Comment

Share via
Copy link
Powered by Social Snap