似乎下载对话框不是 DOM ,因此
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
dr = webdriver.Ie(executable_path="IE.exe")
# EXAMPLE -- download ZIP Jun 20,2018
dr.get('https://usda.library.cornell.edu/concern/publications/j098zb09z?locale=en')
download_CSV =driver.dr.dr.find_element_by_css_selector('#j6731631h > div').click()
# Find the download dialog-box and click save but no function in python selenium.
如何通过什么样的库在Python中应用这些函数?
using System.Windows.Forms;
SendKeys.SendWait(@"C:\Users\Public\Pictures\Sample Pictures\Dock.jpg");
SendKeys.SendWait(@"{Enter}");
CheryJose 的解释清楚地表明对话框不是 DOM 之一
Selenium Web Driver Cancelling Firefox Downloads
如何与Python中的这些脚本结合? 控制下载对话框 - 这些目录并单击“确定”
最佳答案
请引用this thread ,您可以使用 send_keys 方法和 Keys.ENTER:
from selenium.webdriver.common.keys import Keys
driver.find_element_by_id("element_id").send_keys(Keys.ENTER)
以下是一些相关文章,您可以引用:
关于python - 如何在 Python 中使用 Selenium 控制 WINDOW 下载 dialga-box 打开/保存/取消,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56250385/