We are working with Selenium webdriver for UI testing for Internet Explorer 11. In the test web application, several screens pop up. In some tests we ended up with three browser windows and therefore three Driver.WindowHandles. To switch from one WindowHandle to another, we expect Driver.WindowHandles to be sorted with the oldest window first and the newest window last. But that's not the case: it's completely random!
Because windowhandle is a GUID, we end up creating a dictionary with the WindowHandle GUID as the key and the value as the value for the type of page loaded in the browser window. But this will also cause the dictionary to be maintained when the window is closed.
Seems like a lot of work for such a simple thing. Is there a better solution?
You are absolutely right:
In a discussion, Simon clearly mentioned:
So we will raise
WebDriverWait
, then collect the window handle every time a new tab/window is opened, and finally iterate over the window handle andswitchTo().window( newly_opened)
As needed:Java:
Console output:
other
You can find discussions based on python at Open Web Selenium Python in a new tab p>