Skip to content Skip to sidebar Skip to footer

Downloading PDF From Popup/form With Selenium Python ChromeDriver

Having trouble figuring out the next step, trying to download a pdf file from a website and getting stuck. 'https://www.southtechhosting.com/SanJoseCity/CampaignDocsWebRetrieval/S

Solution 1:

Please try this:

chromeOptions = webdriver.ChromeOptions()
prefs = {"plugins.always_open_pdf_externally": True}
chromeOptions.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(chrome_options=chromeOptions)
driver.get('https://www.southtechhosting.com/SanJoseCity/CampaignDocsWebRetrieval/Search/SearchByElection.aspx')

#Code to open the pop-up
driver.find_element_by_xpath('//*[@id="ctl00_DefaultContent_ASPxRoundPanel1_btnFindFilers_CD"]').click()
driver.find_element_by_xpath('//*[@id="ctl00_GridContent_gridFilers_DXCBtn0"]').click()
driver.find_element_by_xpath('//*[@id="ctl00_DefaultContent_gridFilingForms_DXCBtn0"]').click()

driver.switch_to.frame(driver.find_element_by_tag_name('iframe'))
a = driver.find_element_by_link_text("Click here")
ActionChains(driver).key_down(Keys.CONTROL).click(a).key_up(Keys.CONTROL).perform()

UPDATE: To exit the popup, you can try this:

driver.switch_to.default_content()
driver.find_element_by_xpath('//*[@id="ctl00_GenericPopupSizeable_InnerPopupControl_HCB-1"]/img').click()

Post a Comment for "Downloading PDF From Popup/form With Selenium Python ChromeDriver"