2014-01-21 28 views
1

我試圖運行parllel JUnit測試轉換爲java.lang.String中,做了網格設置有3個節點,在執行測試有一個例外WedDriverException:java.util.HashMap中不能初始化時RemoteWebDriver

org.openqa.selenium.firefox.NotConnectedException:無法在45000 ms後在端口7055上連接到主機127.0.0.1。

我的理解是與Firefox和硒版本沒有關係,我認爲這個異常是由於firefox發佈的一個webdriver實例,它沒有在45000毫秒內發佈,這會引發其他webdriver超時異常例如試圖在同一時間上的端口7055連接(蟎是因爲系統緩慢)

所以我相信使用下面的代碼

DesiredCapabilities capablities = new DesiredCapabilities(); 

    FirefoxBinary firefoxBinary = new FirefoxBinary(); 
    firefoxBinary.setTimeout(120000); 


    FirefoxProfile profile = new FirefoxProfile(); 
    profile.setAcceptUntrustedCertificates(true); 
    profile.setAssumeUntrustedCertificateIssuer(false); 

    capablities = DesiredCapabilities.firefox(); 

    capablities.setCapability("firefox_binary", firefoxBinary); 
    capablities.setCapability("firefox_profile", profile); 

    driver = new RemoteWebDriver(new URL("http://" + parameters.getRemoteUrl() + ":4444/wd/hub"), capablities); 

增加在這種情況下超時,但再有一個例外WedDriverException :java.ut il.HashMap不能被轉換爲java.lang.String

爲firefoxbinary

capablities.setCapability("firefox_binary", firefoxBinary); 

否則RemoteWebdriver實例被創建的設置功能時,不會出現任何問題時拋出此異常

請讓我知道如果我是正確的增加關於7055端口的鎖定超時,如果這麼好心地幫助我解決在Firefox中的web驅動程序異常二進制

回答

0

我不知道如果原來的電子郵件您收到的rror(無法連接到端口7055上的主機127.0.0.1)是由於超時問題。我相信它與您使用的硒和firefox版本有關。看看similar question和我的答案,如果你還沒有。我相信你需要升級你的硒版本,如果你不使用最新的。

0

我有同樣的問題

這段代碼在我的本地PC上工作。

FirefoxProfile fp = new FireFoxProfile(); 
fp.setPreference("Firefox43", "43.0.1");   
File pathBinary = new 
     File("C:\\PathToFirefox\\firefox.exe"); 
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);  
WebDriver driver = new FirefoxDriver(firefoxBinary, fp); 

但是這個代碼,不...

FirefoxProfile fp = new FirefoxProfile(); 
fp.setPreference("Firefox43", "43.0.1"); 
File pathBinary = new 
     File("C:\\PathToFirefox\\firefox.exe"); 
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);   
capabilities.setCapability(FirefoxDriver.PROFILE, fp); 
capabilities.setCapability(FirefoxDriver.BINARY,firefoxBinary); 
WebDriver driver = new RemoteWebDriver(new URL(hubUrl), capabilities); 

似乎有與RemoteWebDriver錯誤,請檢查 this question

UPDATE !!!!!

用途:

capabilities.setCapability(FirefoxDriver.BINARY, new 
      File("C:\\PathToFirefox\\firefox.exe")); 

而不是...

File pathBinary = new 
      File("C:\\PathToFirefox\\firefox.exe"); 
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary); 
capabilities.setCapability(FirefoxDriver.BINARY,firefoxBinary); 
+1

你認爲這個問題可以被視爲您已鏈接的一個項目重複?萬一,它應該被標記爲這樣。 –

+0

它是相關的,不是重複的。 –