open new tab with selenium not focused

  • 1 Replies
  • 955 Views
open new tab with selenium not focused
« on: June 06, 2016, 20:13:50 pm »
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

Re: open new tab with selenium not focused
« Reply #1 on: June 14, 2016, 09:55:50 am »
Try this:

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

 

Sitemap 1 2 3 4 5 6 7 8