python - 如何在 Python 中使用 Selenium 控制 WINDOW 下载 dialga-box 打开/保存/取消

标签 python selenium internet-explorer selenium-webdriver dialog

似乎下载对话框不是 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 selenium.webdriver.common.keys.Keys.ENTER() Examples

ENTER key press using Selenium WebDriver with python

关于python - 如何在 Python 中使用 Selenium 控制 WINDOW 下载 dialga-box 打开/保存/取消,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56250385/

相关文章:

python - 在树莓派 3 上使用 selenium 和 chromedriver 时出错 - Raspbian Jessie

javascript - 使用 JavaScript 读取自定义 HTML 元素在 IE 中不起作用

html - Microsoft 是否有 HTML5 服务器发送事件的等效项?

python - 记录文件打开调试的位置 "ResourceWarning: unclosed file"

java - 如何使@FindBy常量的.properties文件编译时间

selenium - 无法使用 Katalon Studio 单击上下文菜单项

html - CSS - 中心位置在具有绝对位置的 IE 中不起作用

python - 使用 cx_Freeze 从导入 Pandas 的 Python3.6 脚本构建可执行文件时出错

python - 艰难地学习 Python,练习 20,对函数感到困惑

python - django cms - 在此服务器上找不到请求的 URL/en/- postgresql、nginx、gunicorn