Receiving org.openqa.selenium.WebDriverException:

2020-06-19 07:35发布

问题:

I keep on getting the following errors when I attempt to run tests in Selenium IDE with Webdriver playback.

Caused by: org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA
Build info: version: ’2.32.0′, revision: ’6c40c18′, time: ’2013-04-09 17:22:56′
System info: os.name: ‘Windows 7′, os.arch: ‘amd64′, os.version: ’6.1′, java.version: ’1.6.0_39′
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.Executable.(Executable.java:72)
at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:59)
at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:55)
at org.openqa.selenium.firefox.FirefoxDriver.getBinary(FirefoxDriver.java:175)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:100)
… 14 more

The error mentions not finding the firefox binary in PATH. I updated the Firefox binary in the path and I still receive the same error message. The functions used in the test case were one custom case and waitforelementpresent.

This is the variable value that I have in my path C:\Program Files (x86)\Firefox ESR 17

How can I resolve this?

回答1:

i updated the enviroment variable path but it didn't work for me. Don't add firefox.exe in the end e.g. E:\installed\Firefox Mozilla. And restart the eclipse. It worked for me.



回答2:

I was also suffering from the same issue. Finally I resolved it by setting binary value in capabilites as shown below. At run time it uses this value so it is must to set.

DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setCapability("platform", Platform.ANY);
capability.setCapability("binary", "/ms/dist/fsf/PROJ/firefox/16.0.0/bin/firefox"); //for linux

//capability.setCapability("binary", "C:\\Program Files\\Mozilla  Firefox\\msfirefox.exe"); //for windows                
WebDriver    currentDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);

And you are done!!! Happy coding :)



回答3:

Add the whole path including name of the exe file as shown below to the path.

C:\Program Files (x86)\Firefox ESR 17\firefox.exe


回答4:

I too had same problem but somehow I've resolved this issue by,

  1. updating my JAR Files: selenium-java-2.43.0.jar to selenium-java-2.48.2.jar and selenium-server-standalone-2.43.1.jar to selenium-server-standalone-2.48.2.jar
  2. Added a new JAR file selenium-java-2.48.2-srcs.jar to lib

These changes made my code flawless in my case



回答5:

In selenium, if you are using chrome driver, then org. openqa. Selenium. WebDriverException mainly shows when the chrome releases a new chrome driver. So try to use the latest chrome driver, and check whether the issue is solved.



回答6:

Just specify the path by doing:

System.setProperty("webdriver.firefox.bin", "C:\\Program Files\\Mozilla Firefox\\firefox.exe");

This will solve the issue.