Wednesday 2 September 2015

Right Click Operations

public class RightClick {

    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(".//*[@id='sblsbb']/button/span")).click();
       
           WebElement e=d.findElement(By.linkText("Selenium - Web Browser Automation"));
       
        Actions a = new Actions(d);
       
//a.contextClick(d.findElement(By.linkText("Selenium - Web Browser Automation"))).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();;
       
        Actions action = new Actions(d).contextClick(e);
        Thread.sleep(6000);
        action.sendKeys(Keys.ARROW_DOWN);
        Thread.sleep(6000);
        action.sendKeys(Keys.ENTER).build().perform();;
       
    }
   
   
}

No comments:

Post a Comment