I need to open a separate window from a link in my main page and leave the main opened. I am using the following code to do so:

self.find_element_by_locator(locator="css==a[href='#/vehicles']").send_keys(Keys.CONTROL + Keys.RETURN)

Then I need to do some stuff in the new window, so I try to switch the focus to it:

windows = self.driver.window_handles

Problem: - The window opens correctly but the focus remains on the main window. (in this case, the Error is that the index is out of range) When I make a Breakpoint and look into the windows I see there is only one element in the list, which refers to the main page and the new page doesn't appear. I also tried opening a new Tab (sending keys Control 't' and then sending keys CONTROL TAB) but the problem remains (The window handles only sees one page or tab)

There is a similar Question but even the implicit_wait doesn't help.

I saw many people having the same problem, but still can't find an answer. Do I have to create a completely other WebDriver or is there easier ways to resolve this problem?

I'm working on Windows10 64Bit / Selenium 3.4.3 / Python 3 and IE11 (IEDriverServer_x64_3.4.0)

  • What about other browsers, does the exact same test pass in other browsers - Chrome, Firefox?
    – alecxe
    Commented Jul 31, 2017 at 16:31
  • I can't really say. I need it to run on IE since it's required by the project. Commented Jul 31, 2017 at 16:32
  • I am just trying to isolate the issue..trying to see if it is browser-specific.
    – alecxe
    Commented Jul 31, 2017 at 16:36
  • Was there any progress with this? I am also sometimes experiencing this. Selenium+Java on IE11 and Chrome. Is it a Selenium issue? Intermittently failing to switch to a new tab or window.
    – Mate Mrše
    Commented Apr 23, 2019 at 9:49

2 Answers 2


In my case, before switch to the new window, a simply thread sleep make thing done.


# switch to new window

Can try this: Before you switch to a newly open tab, try to wait for a while, e.g.

WebDriverWait(browser, 5).until(EC.number_of_windows_to_be(2))

The number 2 if you're open the second tabs ;3 if you're switching to that third tabs

But I'm not really sure.

Correct me if I'm wronged

Hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.