【问题标题】:Cannot upload a file using autoit in selenium python IE 11无法在 selenium python IE 11 中使用 autoit 上传文件
【发布时间】:2020-06-03 22:17:39
【问题描述】:

我在尝试使用 autoit 在 IE 11 中上传时遇到问题

这是我使用的python代码:

filePath = "file_to_upload.txt"
autoit.control_focus("Choose File to Upload","Edit1")
autoit.control_set_text("Choose File to Upload","","Edit1",filePath)
autoit.control_click("Choose File to Upload","","Button1")
driver.find_element_by_xpath('//*[@id="fileUpload"]').send_keys(filePath)

当我运行我的 python 脚本时,我遇到了这个问题:

文件“C:\Users\gc54734\Desktop\Automation\Python\importar_ok_DFT.py”,第 61 行,在 autoit.control_focus("选择要上传的文件","Edit1") 包装器中的文件“C:\Program Files (x86)\Python\Python36-32\lib\site-packages\autoit\autoit.py”,第 84 行 引发 AutoItError(err_msg) autoit.autoit.AutoItError:找不到窗口/控件

我也在尝试这个,没有成功(文件上传窗口打开了,但是文件没有被选中):

driver.find_element_by_xpath('//*[@id="fileUpload"]').send_keys(filePath)

autoit.win_activate("Choose File to Upload")
autoit.control_set_text("Choose File to Upload","","Edit1",filePath)
autoit.control_click("Choose File to Upload","","Button1")

你能给我一个额外的帮助吗?

【问题讨论】:

    标签: python selenium autoit


    【解决方案1】:

    已经 8 个月了,但我遇到了类似的问题。解决方案是在点击按钮和寻找打开的窗口之间增加 5 秒的睡眠时间。

    【讨论】:

      猜你喜欢
      • 2018-11-13
      • 2019-09-20
      • 2015-12-19
      • 1970-01-01
      • 2014-07-14
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多