Use of Robot class in selenium

Robot class is another way to simulate keyboard event in Selenium like Action class.
Normally it's not specific to selenium it's java concept.

By using Robot class we can do keyboard event functionalities.

Mostly all functionalities we will do by using

keyPress()
keyRelease()

Each key has to be press and release respectively.


Ex: 


public class Flipkart{
    public static void main(String[] args) throws InterruptedException, AWTException, IOException {
        WebDriver driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.navigate().to("http://www.Flipkart.com/");
        WebElement women = driver.findElement(By.xpath("xpath"));
        
        Point coordinate1 = men.getLocation();
        Robot robot = new Robot();
        robot.mouseMove(coordinate1.getX()+30, coordinate.getY()+120);
        Thread.sleep(10000);
        driver.findElement(By.xpath("menjeansxpath")).click();
        driver.findElement(By.xpath("//div[@id='login']//div[@class='close']")).click();
        
    }
}

Copyright © 2017 qatoolsguide.blogspot.com || ALL RIGHTS RESERVED