How to scroll down a webpage in selenium using Java?

0 votes
I have a webpage open using selenium and now I want to scroll down. How can I get it done?

Please help.
Dec 17, 2018 in Selenium by Anjali
• 2,940 points
9,314 views

2 answers to this question.

0 votes

Hello @User,

In order to scroll the web page you can use JavascriptExecutor. 

Create an object for JavascriptExecutor and call the webdriver. Then execute the script with a scrollTo function and using that you can either scroll to a particular section or to the bottom of your page.

Here is the script for doing this:

JavascriptExecutor js = ((JavascriptExecutor) driver);
js.executeScript("window.scrollTo(0, document.body.scrollHeight)");
Thread.sleep(5000);

We are using thread.sleep to give the browser a time to scroll if you have used driver.close(); then the browser may close before scroll takes place and you may not see the result.

answered Dec 17, 2018 by Nabarupa
0 votes
This works...

JavascriptExecutor jse = (JavascriptExecutor)driver;

jse.executeScript("scroll(0, 500);");
answered Apr 3, 2019 by anonymous

Related Questions In Selenium

0 votes
1 answer

How to scroll the Page up or down in Selenium WebDriver? (using java)

Its pretty simple. Check out the below ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,510 points
9,733 views
+1 vote
2 answers

Is it possible to scroll down in a webpage using selenium webdriver programmed on python?

I using next code for facebook for ...READ MORE

answered May 16, 2019 in Selenium by mslavikas@gmail.com
11,194 views
0 votes
1 answer

How to scroll up/down a page using Actions class in Selenium?

Hi Naetik, you can use Actions class ...READ MORE

answered Jul 4, 2019 in Selenium by Anvi
• 14,010 points
2,166 views
0 votes
1 answer

How to wait for the webpage to load in selenium using java

Firstly, when you launch a web application, ...READ MORE

answered Aug 28, 2018 in Selenium by bug_seeker
• 15,390 points
299 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
1,542 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,850 points
1,486 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,850 points
1,265 views
0 votes
1 answer

How to get the HTML source of a webpage using Selenium in Java?

There is a method called getPageSource() in ...READ MORE

answered Jan 10, 2019 in Selenium by Sneha
2,306 views
+1 vote
2 answers

How to get the title of a webpage using Selenium Java?

Essentially, driver.getTitle(); function can be used to ...READ MORE

answered Dec 17, 2018 in Selenium by Vardhan
• 13,070 points
1,231 views