Selenium 4.0 Command to Open New Window & Tab - Codoid
Select Page
Codoid Blog

Selenium 4.0 Command to Open New Window & Tab

Irrespective of the business that your client is in, marketing is an integral part of their operations. In fact, in this day and age of social.

In Selenium 4.0, you can open new window & tab using “newWindow” command. Please note: Selenium 4.0 is yet to be released. However, you can try this feature using Firefox 66 & Selenium 4.0.0-alpha-1 versions.

Selenium 4.0 (Alpha) Maven Dependency

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-alpha-1</version>
</dependency>

Code

System.setProperty("webdriver.gecko.driver", "drivers/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.switchTo().newWindow(WindowType.WINDOW);
driver.switchTo().newWindow(WindowType.TAB);

Follow our blog to receive Selenium related updates.

Written By

Submit a Comment

Your email address will not be published. Required fields are marked *


In Selenium 4.0, you can open new window & tab using “newWindow” command. Please note: Selenium 4.0 is yet to be released. However, you can try this feature using Firefox 66 & Selenium 4.0.0-alpha-1 versions.

Selenium 4.0 (Alpha) Maven Dependency

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-alpha-1</version>
</dependency>

Code

System.setProperty("webdriver.gecko.driver", "drivers/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.switchTo().newWindow(WindowType.WINDOW);
driver.switchTo().newWindow(WindowType.TAB);

Follow our blog to receive Selenium related updates.