Selenium 4 — Switch to a new window or a new tab

Dheeraj Gambhir
1 min readNov 27, 2019

--

If you have a use case where after navigating to a site you need to open another tab or a window and then navigate to some site on the new tab/window to perform some action there- then you can use these commands from Selenium 4:

driver.switchTo().newWindow(WindowType.TAB); driver.switchTo().newWindow(WindowType.WINDOW);

Tried and tested- works fine.

--

--

No responses yet