AutoIt成功浏览了文件,但是webdriver生成了“UnreachableBrowserException”错误

时间:2016-11-14 15:11:11

标签: java eclipse selenium-webdriver autoit

使用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);

可能出现什么问题?

2 个答案:

答案 0 :(得分:2)

此问题的主要原因是在后台运行多个gecko驱动程序。要解决:转到任务管理器(Ctrl + Alt + Delete),在进程选项卡中,在后台进程下,终止所有gecko驱动程序实例并重新运行webdriver。这对我有用,消除了UnreachableBrowserException: Error communicating with the remote browser错误

答案 1 :(得分:0)

要添加到@AutoQA不错的答案,最好在driver.dispose()子句(或finally)中使用@AfterClass来处理closing instances,或者创建一个脚本使用类似的东西(对于Windows)来结束这些实例:

taskkill /F /IM geckodriver.exe
相关问题