【发布时间】:2016-07-26 19:07:02
【问题描述】:
使用 Python 中的 Selenium Webdriver 我打开一个网页,然后单击“文件上传”表单(是 HTML5,它是一个 DIV,它不是表单 HTML 元素,但它并不关心很多),单击它后出现问题,出现“文件打开”窗口并询问文件。现在是我想放置文件路径并使用 AutoIt 按 Enter 键(或单击“打开”按钮)的时候。
但是我不能用 WinActivate 做到这一点,因为 AutoIt 似乎找到了它,但它就是不正确的,因为 AutoIt 给我的句柄不等于我用 AutoIt 窗口信息工具看到的句柄。
$title = 'Open'
WinActivate($dialogtitle)
If WinActive($dialogtitle) Then
MsgBox(0, "Found", "Window found.")
send("D:\documents\photo.jpg")
Send("{ENTER}")
Else
MsgBox(0, "Not found", "Window not found.")
EndIf
它在 Firefox 上完美运行,但在 Chrome 和 MS Edge 上却不行。
【问题讨论】:
标签: google-chrome file-upload image-uploading autoit microsoft-edge