无法找到/打开Firefox的二进制 - 的webdriver /机器人框架无法找到/打开Firefox的二进制 - 的webdriver /机器人框架
我的测试运行在Java和FitNesse的罚款。使用Internet Explorer和Chrome通过机器人框架执行它们时,它们也运行良好。然而,当我通过火狐执行它们,使用“新FirefoxDriver()”时,收到以下错误:
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
在FirefoxBinary和FirefoxDriver类这些线对应于以下代码:
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);
}
我已经尝试在我的classpath,pythonpath(由robotframework使用)和路径中设置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代码中创建一个。我已经尝试过Firefox 6-8。不幸的是,这些事情都没有奏效。
我也使用/已使用: 的Java 1.6 硒2.9.0/2.13.0 Windows 7的
我不能确定这是否是相关的,但作为一个解决办法,我一直试图让火狐通过远程浏览器运行。我一直在尝试下面的代码:
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)
有没有人对如何解决或者我的问题任何想法?
任何帮助将不胜感激,我感到非常卡住在这个问题atm。当Internet Explorer已经做了两天的尝试让Firefox工作......感觉好像这个世界即将结束。
谢谢, 詹姆斯
编辑:1
这是我能够通过使用硒服务器上运行的Firefox。
詹姆斯,仅供参考,网址为RemoteWebDriver出现在上面的帖子不正确。应该更像“http:// localhost:4444/wd/hub”?有趣的是,我遇到与Web Driver相反的问题,通过RemoteWebDriver启动Firefox时遇到问题,但Firefox通过本机FirefoxDriver运行正常。 IE在远程工作正常。 – David