1

我收到错误:

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

我正在使用Selenium v 2.30Firefox v.19开启windows 8 64bit

相同的代码在 windows7/SP1 上运行良好。

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

2 回答 2

3
  1. 打开命令行(开始 -> 运行 -> 键入“cmd”)
  2. 类型PATH
  3. 验证您是否可以在此处看到写在firefox.exe某处

它没有帮助然后像这样更改构造函数:

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;
}
于 2013-02-25T08:13:30.807 回答
0

你可以做

System.setProperty("webdriver.firefox.bin","PATH_TO_BINARY");
于 2014-06-05T12:31:26.000 回答