無法找到/打開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