【问题标题】:How to select file with AutoIt in "File Open" window on Chrome and Edge如何在 Chrome 和 Edge 的“文件打开”窗口中使用 AutoIt 选择文件
【发布时间】: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


    【解决方案1】:

    这可能晚了, 但这就是我的做法,用窗口上显示的文本更改“打开文件”

    import autoit
    autoit.win_wait_active("Open File", 5)
    autoit.send(path)
    autoit.send("{ENTER}")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-31
      • 2015-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多