【发布时间】:2019-10-17 11:54:49
【问题描述】:
我想使用 Selenium 保存 this file。我可以使用以下代码单击“另存为”:
driver = webdriver.Chrome(chrome_options=options, executable_path = chrome_driver_path)
driver.get('https://www.shs-conferences.org/articles/shsconf/pdf/2019/06/shsconf_m3e22019_03006.pdf')
ActionChains(driver).move_to_element(driver.find_element_by_xpath('//*[@id="plugin"]')).key_down(Keys.CONTROL).send_keys('s').key_up(Keys.CONTROL).perform()
但是,我无法让 python 在弹出窗口中按下“保存”底部。我试过了:
driver.find_elements_by_xpath("//*[contains(text(), 'Save')]").click()
和
ActionChains(driver).send_keys(u'\ue007').perform()
有人知道如何点击底部的“保存”吗?
【问题讨论】:
-
有比使用 selenium 下载 pdf 文件更好的方法。在这里查看答案 - stackoverflow.com/questions/24844729/download-pdf-using-urllib
-
@Sureshmani 这不是用户要求的。如果您打算提供一种替代方法,您还应该概述如何在 Selenium 中执行此操作,并解释为什么这不是一个好主意。