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.edureka.co/");
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);
}
}