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 in Selenium by Naetik
340 views

1 answer to this question.

0 votes

Hi Naetik, you can use Actions class in Selenium to perform page scroll up/down. 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 4 by Anvi
• 12,860 points

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,090 points
7,249 views
0 votes
2 answers

How to scroll down a webpage in selenium using Java?

This works... JavascriptExecutor jse = (JavascriptExecutor)driver; j ...READ MORE

answered Apr 3 in Selenium by anonymous
3,219 views
+1 vote
2 answers
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,090 points
603 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,130 points
904 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,130 points
590 views
0 votes
1 answer