在路径中找不到firefox二进制文件

时间:2013-02-25 06:50:06

标签: java firefox selenium windows-8

我收到错误:

Failed: org.openqa.selenium.WebDriverException Cannot find firefox binary in PATH, make sure firefox is installed. OS appears to be WIN8

我在Selenium v 2.30

上使用Firefox v.19windows 8 64bit

相同的代码在windows7 / SP1上完美运行。

if(browser == SupportedBrowser.FIREFOX) {           
           //firefox driver is built into selenium standalone server
           return new FirefoxDriver();
       }

2 个答案:

答案 0 :(得分:3)

  1. 打开命令行(开始 - >运行 - >输入“cmd”)
  2. 输入PATH
  3. 确认您可以在此处看到firefox.exe某处
  4. 他没有帮助然后像这样更改构造函数:

    if(browser == SupportedBrowser.FIREFOX) { 
      File pathToBinary = new File("path/to/firefox.exe");
      FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
      FirefoxProfile firefoxProfile = new FirefoxProfile();
      FirefoxDriver _driver = new FirefoxDriver(ffBinary,firefoxProfile);
      return _driver;
    }
    

答案 1 :(得分:0)

你可以做到

System.setProperty("webdriver.firefox.bin","PATH_TO_BINARY");