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

0 votes
How to scroll up/down a page using Actions class in Selenium?
Jul 4, 2019 in Selenium by Naetik
20,590 views

1 answer to this question.

0 votes

Hi Naetik, you can use the Actions class to perform, scroll down in Selenium, or scroll up. Following test script uses Actions class to Scroll Up/Down a page:

import java.io.IOException;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class Page_Scroll_Actions {

   public static void main(String[] args) throws IOException {

      System.setProperty("webdriver.gecko.driver", "D:\\geckodriver.exe");

      WebDriver driver = new FirefoxDriver();

      driver.get("https://www.amazon.com/");

      Actions actions = new Actions(driver);

      // Scroll Down using Actions class
      actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();

      // Scroll Up using Actions class
      actions.keyDown(Keys.CONTROL).sendKeys(Keys.HOME).perform();
   }
}
answered Jul 5, 2019 by Anvi
• 14,150 points
Thanks it works for scroll down
Hey @Lakshmi, thanks for your contribution. Please upvote the answer in case you found it helpful!

Related Questions In Selenium

0 votes
2 answers

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

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
18,910 views
0 votes
5 answers

How to scroll down a webpage in selenium using Java?

 to scroll up or down with Selenium, a JavaScript executor is a ...READ MORE

answered Dec 16, 2020 in Selenium by Roshni
• 10,480 points
44,635 views
0 votes
1 answer
+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
26,073 views
0 votes
2 answers

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,500 points
13,673 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,142 views
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,910 points
7,221 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,874 views
0 votes
1 answer
0 votes
2 answers

How to scroll a Web Page using coordinates of a WebElement in Selenium WebDriver ?

JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("window.scrollBy("X", " y ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
6,124 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP