Is it possbile to perform page scroll up down using Robot class in Selenium

0 votes
Is it possbile to perform page scroll up/down using Robot class in Selenium?
Jul 4, 2019 in Selenium by Ashwin
2,473 views

1 answer to this question.

0 votes

Hey Ashwin, yes it is possible to scroll up/down a webpage using Robot Class in Selenium. Following code snippet performs the same action using robot class:

import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Scroll_Page {

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

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

        WebDriver driver = new FirefoxDriver();

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

        Robot robot = new Robot();

        // Scroll Down using Robot class
        robot.keyPress(KeyEvent.VK_PAGE_DOWN);
        robot.keyRelease(KeyEvent.VK_PAGE_DOWN);

        // Scroll Up using Robot class
        robot.keyPress(KeyEvent.VK_PAGE_UP);
        robot.keyRelease(KeyEvent.VK_PAGE_UP);
     }
}
answered Jul 4, 2019 by Anvi
• 14,150 points

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 5, 2020 in Selenium by Sri
• 3,010 points
14,938 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
21,926 views
0 votes
0 answers
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,520 points
5,067 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,010 points
5,808 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,890 points
3,575 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 2, 2020 in Selenium by Sri
• 3,010 points
4,310 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,150 points
12,281 views
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,010 points
2,815 views