Hello Folks,

In last post, we have learnt to scroll a web page by pixels. In this post, we will see how to scroll a web page , page by page.

What is page in Web page?

Follow below steps:

  1. Open browser and load url “http://www.makeseleniumeasy.com/“.
  2. Wait till page is loaded.
  3. Now press Key “Page Down” and notice how much page is scrolled down. You have scrolled web page by a page.
  4. If you keep pressing “Page Down” key, you will reach bottom of page.

The same we can achieve using javascript in selenium webdriver.

Java code:

  1. First we need to get page height of one page.
  2. Then we need to get how much is scroll-able height. Generally it will be “Height of a page* No of pages”.
  3. Now get number of pages. It will be number of times of pressing “Page Down” key to get bottom of page.

Java Code:

When you run the program, you will notice page is scrolled down page by page till it reaches to bottom of the web page.

That’s it guys in this post. We will see some more interesting thing about scroll in up coming posts.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply