Selenium: Safari switch_to_window_handles not working in safari 13.0.1

Created on 28 Sep 2019  路  6Comments  路  Source: SeleniumHQ/selenium

馃悰 Bug Report

Getting webdriver exception at the below command.
driver.switch_to.window(handles)
Configuration details:
Selenium version = 3.141.0
Safari version = 13.0.1
MacOS version = mojave 10.14.6

R-awaiting answer

Most helpful comment

@jagruthim "It works fine in chrome browser" means nothing more than that you got lucky that the window handles just happened to be returned in that order, this time. It's not cross-browser to assume that, and it's not guaranteed that the driver for Chrome will always behave that way.

All 6 comments

Please provide an SSCCE (Short, Self Contained, Correct [compilable] example) http://sscce.org/

Description: After clicking on login there is a window which is displayed to enter the username and password. To enter the credentials, switching to that window is necessary. The index of initial page is 0 and the credentials window is 1. I am trying to switch to that window and it doesn't in safari. It works fine in chrome.
Sample code:
handles = driver.window_handles
size = len(handles)
print (size) // this displays 2(index 0 and 1)
driver.switch_to.window(handles[1])
@barancev

@jagruthim The handles returned by window_handles is not guaranteed to be in any order. This means that handles[1] is not guaranteed to be the newly opened window. That may not be the cause of the issue, but it鈥檚 something you鈥檒l want to account for in your code.

@jimevans I can try to change the code but it works fine in chrome browser.

@jagruthim "It works fine in chrome browser" means nothing more than that you got lucky that the window handles just happened to be returned in that order, this time. It's not cross-browser to assume that, and it's not guaranteed that the driver for Chrome will always behave that way.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gauntface picture gauntface  路  3Comments

ghost picture ghost  路  4Comments

VishnuAtDevopStation picture VishnuAtDevopStation  路  3Comments

PaziewskiCezary picture PaziewskiCezary  路  3Comments

theproshin picture theproshin  路  3Comments