I recently got help with downloading a PDF file from a popup form, but now I would like to exit the form and for some reason I can't perform any actions after downloading the PDF.
I've tried ActionChains(driver).send_keys(Keys.ESCAPE).perform()
and it doesn't exit the form. I've also tried driver.back()
but that goes back one page and I would like to stay on the current page to continue downloading files.
Here's the code so far:
options = webdriver.ChromeOptions()
prefs = {"download.default_directory":"C:/Users/gille/Documents/SJ Webscraping/data","plugins.plugins_list":[{"enabled":False,"name":"Chrome PDF Viewer"}]}
options.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(options=options)
driver.get("https://www.southtechhosting.com/SanJoseCity/CampaignDocsWebRetrieval/Search/SearchByElection.aspx")
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_elements_by_xpath('//td[@class="dxgvCommandColumn_Glass dxgv"]//img[@title="View Form"]')[0].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()
#insert exit sequence here