How to open New Tab in Chrome and Firefox?

(thomas salai) #1

Dear All,

I have a problem with Selenium 3 to open a new tab in Firefox and Chrome.

SeleniumTestBase.getDriver().findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"\t");

Doesn’t work in Chrome and Firefox.

I could use the following code for Chrome but not for Firefox, in Firefox it open new Windows.

 JavascriptExecutor js = (JavascriptExecutor) SeleniumTestBase.getDriver();

I used currently:

selenium-server-standalone: 3.8.1
chromedriver: 2.34
geckodriver: 0.19.1

Many thanks in advance.

Bes Regards,


(Giuseppe) #2

HI Thomas,

A clean approach is to use the Actions

Actions act = new Actions(driver);