TestProject Forum
Powered by leading experts in the test automation community

Open new tab with selenium not focused

I want to do some testing on a new tab in chrome

I can switch to the new tab with window handle switchTo, but when I try to do something I get an exception “no such element exception”… probably since it is with focus on previous tab

Try this:

Set<String> windowsSet = driver.getWindowHandles();
List<String> windowsList = new ArrayList<String>(windowsSet);
String newTab = windowsList.get(windowsList.size() - 1);
driver.switchTo().window(newTab);