selenium python - leaving pop up window hangs

Viewed 273

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

  1. Click link on the page which opens pop up window

  2. Select link on pop up window and click it

  3. Do something else on 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 for opening pop up window, selecting frame and clicking link on that frame. Pop up is closed (which is correct) but selenium hangs after that and print statement with "Expecting window to close" never gets executed. It looks very strange especially that selenium never timeouts and keeps hanging until process is manually interrupted.

EDIT:

It looks that it can be a problem with geckodriver, I executed code with chromedriver and it worked.

0 Answers
Related