【发布时间】:2017-03-28 06:43:09
【问题描述】:
使用 controlFocus 方法:
ControlFocus("File Upload", "", "Edit1")
ControlSetText("File Upload", "", "Edit1", "C:\Test.2.0.war")
ControlClick("File Upload", "", "Button1"
AutoIt 成功浏览并在 Firefox 中打开了一个文件,但是显示了正确的文件名; Selenium webdriver 在此之后无法点击上传按钮,抛出错误:
UnreachableBrowserException: Error communicating with the remote browser.
使用的webdriver代码是:
Runtime.getRuntime().exec("D:\\AutoIT\\FileUpload.exe");
Thread.sleep(5000);
可能出了什么问题?
【问题讨论】:
-
无需使用 Autoit,Selenium 支持文件上传,方法是在 web 元素
<input type=file>上调用sendKeys。 -
Sendkeys 在所有情况下都不起作用。对于这个项目,它可以在 chrome 中运行,但不能在 Firefox 中运行。浏览并打开文件路径后,Firefox 禁用了上传按钮。 AutoIT 解决了这个问题
-
可以使用 Firefox 上传文件,但根据浏览器和驱动程序的版本,您可能需要使用
executeScript的解决方法来显示<input>或触发 @ 987654328@事件。
标签: java eclipse selenium-webdriver autoit