Selenium python - leaving the popup hanging

I want to emulate the following behavior in selenium python (python v2.7, selenium v3.4.2, geckodriver):

  • Click the link on the page that opens the popup

  • Select the link in the pop-up window and click on it

  • Do something else in the main window

I have the following code:

main_window_handle = None
while not main_window_handle:
    main_window_handle = driver.current_window_handle
driver.find_element_by_xpath('//*[@title="Open Search Window"]').click()
search_window_handle = None 
while not search_window_handle:
    for handle in driver.window_handles:
        if handle != main_window_handle:
            search_window_handle = handle
            break
driver.switch_to.window(search_window_handle)
driver.switch_to.frame("resultsFrame")
print "Clicking results frame"
driver.find_element_by_link_text("TestResult").click()
print "Expecting window to close"
driver.switch_to.window(main_window_handle)

      

It works to open a popup, select a frame, and link to that frame. The popup is closed (that's correct), but the selenium hangs after that and the print assertion with "Waiting for window to close" is never executed. It is especially strange that selenium never overheats and lasts until the process is manually interrupted.

EDIT:

It looks like it might be a geckodriver issue, I ran the code with chromedriver and it worked.

+3


source to share





All Articles