Skip to content

Instantly share code, notes, and snippets.

@4M01
Created September 19, 2016 19:04
Show Gist options
  • Save 4M01/b6231856976e45bfc60bd7bbbc46b69e to your computer and use it in GitHub Desktop.
Save 4M01/b6231856976e45bfc60bd7bbbc46b69e to your computer and use it in GitHub Desktop.
Open a blank tab in a browser using Selenium WebDriver for Mac & windows . Please check http://qaperspective.blogspot.in/2016/09/open-new-tab-using-Selenium-WebDriver.html
public void openNewTab() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL + "t");
} else {
driver.findElement(By.cssSelector("body")).sendKeys(Keys.COMMAND + "t");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment