1

Using the controlFocus method:

ControlFocus("File Upload", "", "Edit1")
ControlSetText("File Upload", "", "Edit1", "C:\Test.2.0.war")
ControlClick("File Upload", "", "Button1"

AutoIt successfully browsed and opened a file in Firefox and the correct file name was displayed, however; the Selenium webdriver was unable to click on the upload button after this, throwing an error:

UnreachableBrowserException: Error communicating with the remote browser.

The webdriver code used is:

Runtime.getRuntime().exec("D:\\AutoIT\\FileUpload.exe");
Thread.sleep(5000);

What could possibly be wrong?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • There's no need to use Autoit, File upload is supported by Selenium by calling `sendKeys` on the web element ``. – Florent B. Nov 14 '16 at 18:07
  • Sendkeys doent work in all cases. For this project, it worked in chrome but not in Firefox. Firefox disabled the upload button after the file path was browsed and opened. AutoIT fixed that problem –  Nov 14 '16 at 19:59
  • It's possible to upload a file with Firefox, but depending on the version of the browser and driver you may need to apply a workaround with `executeScript` to either display the `` or to trigger the `change` event. – Florent B. Nov 14 '16 at 22:02

2 Answers2

2

A major cause of this issue is multiple gecko drivers running in the background. To resolve: go to the task manager (Ctrl + Alt + Delete), in the processes tab, under background processes, terminate all the gecko driver instances and rerun webdriver. This worked for me, eliminating the UnreachableBrowserException: Error communicating with the remote browser error

0

To add to @AutoQA nice answer, Better yet take care of closing instances using driver.dispose() in a finally clause (or in @AfterClass), or make a script to end those instances with something like (for Windows):

taskkill /F /IM geckodriver.exe
Community
  • 1
  • 1
Moshisho
  • 2,781
  • 1
  • 23
  • 39