Wednesday, 2 September 2015

How to perform Key Board Operatiionsssss

public class KeyboardOperations {

public static void main(String[] args) throws InterruptedException {
    
        WebDriver d = new FirefoxDriver();
        d.manage().window().maximize();
        d.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);
        d.get("https://www.google.com");
        Thread.sleep(2000);
        d.findElement(By.name("q")).sendKeys("selenium");
        Thread.sleep(2000);
        d.findElement(By.xpath(".//*[@class='sbsb_b']/li[2]/div/div[2]")).click();
        Thread.sleep(2000);
        Actions a = new Actions(d);
       
        a.sendKeys(Keys.END).build().perform();;
        Thread.sleep(2000);
        a.sendKeys(Keys.HOME).build().perform();
        Thread.sleep(2000);
       
        a.sendKeys(Keys.ARROW_DOWN).build().perform();
        Thread.sleep(2000);
        a.sendKeys(Keys.ARROW_UP).build().perform();
        Thread.sleep(2000);
   
        a.sendKeys(Keys.F5).build().perform();
        Thread.sleep(2000);
       
        /*a.sendKeys(Keys.chord(Keys.CONTROL,"s")).build().perform();;
        Thread.sleep(2000);*/
       
        a.sendKeys(Keys.chord(Keys.CONTROL,Keys.SHIFT,"s")).build().perform();
        Thread.sleep(5000);

}
   
}

No comments:

Post a Comment