Reputation: 11
I am trying to open new tab in current WebDriver instance and I am using this command driver.findElement(By.xpath("/html/body")).sendKeys(Keys.CONTROL + "\t");
but it did not work. I am currently using Selenium 2.53 and Firefox version 28 in a Linux system.
Upvotes: 0
Views: 758
Reputation: 4820
All you do by that command is to send some keys so the HTML body. It does not affect the browsers menu at all.
Configuring Firefox for test automation is done by the help of Firefox profiles. So you should create a profile which opens new tabs instead of windows in about:preferences
.
You can then use the profile in your test code by instantiating the driver like this:
WebDriver driver = new FirefoxDriver(new FirefoxProfile(new File("/path/to/ff_profile")));
See javadoc for details.
Upvotes: 1