Switch to popup in python using selenium -


how switch popup window in below selenium program. i've looked possible solutions haven't been able head around them. please help!!

from selenium import webdriver splinter import browser selenium.webdriver.common.keys import keys handle = [] driver = webdriver.firefox() driver.get("http://example.com/test.aspx")  driver.find_element_by_link_text("site actions").click() driver.find_element_by_link_text('edit page').click() select = driver.find_element_by_id('ctl00_placeholdermain_ctl35_ctl00_selectresult') option in select.find_elements_by_xpath('//*[@id="ctl00_placeholdermain_ctl35_ctl00_selectresult"]/option'):             if option.text != 'channel':                 option.select() # select() in earlier versions of webdriver  driver.find_element_by_id('ctl00_placeholdermain_ctl35_ctl00_removebutton').click()  parent_h = driver.current_window_handle  #click activates popup. checkin = driver.find_element_by_id('qacheckin_anchor').click()  # click on link opens new window handles = driver.window_handles # before pop-up window closes driver.remove(parent_h) driver.switch_to_window(handles.pop()) driver.implicitly_wait(10) # seconds driver.find_element_by_xpath('/html/body/form/div[3]/table/tbody/tr[4]/td/table/tbody/tr[3]/td[2]/input').click() driver.find_element_by_name('btnclose2').click() driver.close(); # stuff in popup # popup window closes driver.switch_to_window(parent_h) # , you're  driver.switch_to_default_content() 

in terms of browser, pop not window, alert. so, should use following:

driver.switch_to_alert() 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -