Selenium 无法找到/打开Firefox二进制-webdriver/robot框架

Selenium 无法找到/打开Firefox二进制-webdriver/robot框架,selenium,robotframework,Selenium,Robotframework,无法找到/打开Firefox二进制-webdriver/robot框架 我的测试在java和fitnesse中运行良好。当通过带有Internet Explorer和Chrome的robot框架执行它们时,它们也运行良好。但是,当我使用“new FirefoxDriver()”通过Firefox执行它们时,我收到以下错误: DEBUG java.lang.ExceptionInInitializerError at org.openqa.selenium.firefox.F

无法找到/打开Firefox二进制-webdriver/robot框架

我的测试在java和fitnesse中运行良好。当通过带有Internet Explorer和Chrome的robot框架执行它们时,它们也运行良好。但是,当我使用“new FirefoxDriver()”通过Firefox执行它们时,我收到以下错误:

DEBUG   java.lang.ExceptionInInitializerError 
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java: 81) 
Caused by: java.lang.NullPointerException
org.openqa.selenium.firefox.FirefoxBinary.<clinit>(FirefoxBinary.java: 42) 
        ... 183 more 
我已经尝试在我的类路径、pythonpath(由robotframework使用)和path中设置Firefox二进制文件的路径。我还编写了以下代码行,试图强制查找二进制文件:

System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(FirefoxDriver.BINARY, "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
我试着在两台电脑上执行测试,我的工作电脑和家用电脑。此外,我还尝试使用firefox.exe–p创建的firefox配置文件,以及在java代码中创建的配置文件。我试过Firefox6-8。不幸的是,这些措施都没有奏效

我还使用/曾经使用: Java 1.6 硒2.9.0/2.13.0 视窗7

我不确定这是否相关,但作为一种解决方法,我一直在尝试让Firefox通过远程浏览器运行。我一直在尝试以下代码:

FirefoxBinary ln42-43 
 private static final String PATH_PREFIX = "/" + 
      FirefoxBinary.class.getPackage().getName().replace(".", "/") + "/"; 

and FirefoxDriver ln 80-82 
public FirefoxDriver(FirefoxProfile profile) { 
    this(new FirefoxBinary(), profile); 
  } 
rcc = new RemoteControlConfiguration();
rcc.setPort(4447);
rcc.setPortDriversShouldContact(4447);
rcc.setInteractive(true);
rcc.setSingleWindow(true);
rcc.setTimeoutInSeconds(30);
ss = new SeleniumServer(rcc);
ss.start();
DesiredCapabilities cap = new DesiredCapabilities();

cap.setJavascriptEnabled(true);
cap.setBrowserName("firefox");
URL url = new URL ("http://www.google.com/");
driver = new RemoteWebDriver(url,cap);
但是,当我运行上述命令时,会收到以下错误消息:

Exception in thread "main" org.openqa.selenium.WebDriverException: Error communicating with the remote browser. It may have died.
Build info: version: '2.13.0', revision: '14794', time: '2011-11-18 17:49:47'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0'
Driver info: driver.version: Selenium2Driver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:412)
有人知道如何解决我的问题吗

任何帮助都将不胜感激,在这个问题上我感到非常困惑。在Internet Explorer已经开始工作的情况下,尝试让Firefox工作了两天…。。感觉世界就要结束了

谢谢, 詹姆斯

编辑:1


我可以使用selenium服务器运行Firefox。

James,仅供参考,上面帖子中RemoteWebDriver的URL不正确。应该更像“localhost:4444/wd/hub”;?有趣的是,我在Web驱动程序方面遇到了相反的问题,通过RemoteWebDriver启动Firefox时出现问题,但Firefox通过本机FirefoxDriver运行良好。IE在遥控器上工作正常大卫12月4日11点4分51分


谢谢你,大卫

我不明白您为什么没有在remote grids config.json文件中配置Firefox二进制文件?我会这样做的。然后,您的DesiredCapabilities对象将不需要定义它。可以找到一个提示

如果可行,JSON文件中的行可能如下所示:

"binary": "C:/Program Files/Mozilla Firefox/firefox.exe",
我猜它不允许您从代码中动态设置二进制位置,但也许您可以尝试这种方式来证明它是否应该作为故障排除步骤工作

FirefoxProfile profile = new FirefoxProfile(); 
FirefoxBinary binary = new FirefoxBinary(new File("C:\\path to firefox\\firefox.exe")); 
driver = new FirefoxDriver(binary, profile);

尝试此

由于selenium web驱动程序找不到Firefox的.exe文件而导致此类问题。请检查C:\Program Files(x86)\Mozilla Firefox您的位置中是否有exe文件,并且不要忘记设置具有java jdk路径的环境变量


来源:-读取[已解决无法在路径Selenium中找到firefox二进制文件][1]

James,仅供参考,上面帖子中RemoteWebDriver的URL不正确。应该更像“”吗?有趣的是,我在Web驱动程序方面遇到了相反的问题,通过RemoteWebDriver启动Firefox时出现问题,但Firefox通过本机FirefoxDriver运行良好。遥控器工作正常。