Sunday, January 5, 2014

Open Link In New Tab Using Mouse Click


We can Open link in new tab pressing Control + Left mouse click in firefox.So here we take Google as an example page and open "About" and "+You" in new Tab.

 WebDriver driver = new FirefoxDriver();
 driver.navigate().to("http://www.google.com");

 WebElement oWE = driver.findElement(By.linkText("About"));
 WebElement oWE1 = driver.findElement(By.linkText("+You"));
Actions oAction=new Actions(driver);

oAction.moveToElement(oWE).keyDown(Keys.CONTROL).click(oWE)
                             .keyUp(Keys.CONTROL).perform();

Thread.sleep(1000);
Actions oAction1=new Actions(driver);

oAction1.moveToElement(oWE1).keyDown(Keys.CONTROL).click(oWE1)
                             .keyUp(Keys.CONTROL).perform();


No comments:

Post a Comment