import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class NewTab {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
Actions act = new Actions(driver);
WebElement link = driver.findElement(By.id("gb_70"));
act.moveToElement(link).contextClick().sendKeys("T").perform();
}
}
Hi dude, if you don't mind Can you please explain about this statement. Why contextClick() and sendKeys("T")?
ReplyDeleteact.moveToElement(link).contextClick().sendKeys("T").perform();
contextClick() is used to right click and sendKeys("T") is used to send 'T'.
ReplyDeleteTry manually right click on any link and then press T to open that link in new tab.
Ya got it dude... Thank you.
ReplyDelete