2012-04-04 113 views
4

我有這個問題。當不同的計算機上,我開始HUB和節點,然後運行我的測試中,我初始化谷歌瀏覽器這樣的:Selenium Grid不在另一臺計算機上運行Chrome

Selenium selenium = new DefaultSelenium("localhost", 4444, *googlechrome, "http://www.google.com"); 
DesiredCapabilities capabilities = DesiredCapabilities.chrome(); 
capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized")); 
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities); 

一切都運行在我的電腦就OK了 - Chrome的出現並執行腳本。但是,如果我的朋友試圖做同樣的,她得到這個錯誤:

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Build info: version: 'unknown', revision: 'unknown', time: 'unknown' 
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_29' 
Driver info: driver.version: RemoteWebDriver 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:435) 
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:139) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:102) 
    at com.deutscheboerse.test.PerfTests.<init>(PerfTests.java:52) 
    at com.deutscheboerse.test.EUAStressTest.myTest(EUAStressTest.java:37) 
    at com.deutscheboerse.test.EUAStressTest.main(EUAStressTest.java:60) 
Caused by: org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 4422; received: 3743 
    at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:178) 
    at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:197) 
    at org.apache.http.impl.io.ContentLengthInputStream.close(ContentLengthInputStream.java:105) 
    at org.apache.http.conn.BasicManagedEntity.streamClosed(BasicManagedEntity.java:152) 
    at org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:237) 
    at org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:186) 
    at org.apache.http.util.EntityUtils.consume(EntityUtils.java:67) 
    at org.openqa.selenium.remote.HttpCommandExecutor$EntityWithEncoding.<init> HttpCommandExecutor.java:399) 
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:287) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:415) 
    ... 6 more 

到目前爲止,唯一不同的是我發現的是,那她的樞紐正在監聽http://10.10.190.134:5555礦監聽http://10.131.7.44:5555但都可以訪問控制檯在相同的IP和端口上。我沒有任何線索最新錯誤。一切都讚賞,感謝

**編輯**

Iried到另一臺計算機上運行它和我有同樣的錯誤。小調試表明我這個消息:

11:04:01.899 WARN - Exception: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list 

所以,事先設置了鍍鉻中硒電網,我需要這樣做:

System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, "chromedriver.exe"); 

我試圖做到這一點,還是老樣子無法運行Chrome瀏覽器...任何幫助還是想

EDID2 這是我如何準確地設置屬性:

File file = new File("lib/chromedriver.exe"); 
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, file.getAbsolutePath()); 

我正在使用這種方法,因爲我需要在更多計算機上運行它,並且JAR文件可以具有不同的位置。

順便說一下,在Selenium Grid的角色節點窗口中發現警告。我在想,如果有其他切換器的話。到目前爲止,我正在運行這些命令:

java -jar lib//selenium-server-standalone-2.20.0.jar -role hub 
java -jar lib/selenium-server-standalone-2.20.0.jar -role node -hub http://localhost:4444/grid/register -maxSession 12 

and then my JAR. The exception is in window with the NODE. Is there any switcher? 
+0

嘗試把chromedriver.exe的完整路徑,而不是 – 2012-04-04 13:23:20

+0

編輯一點。基本上全路徑沒有幫助 – 2012-04-04 13:42:28

+0

轉到頁面:http:// localhost:/grid/console並查看是否可以看到任何內容。 – 2012-04-04 13:49:42

回答

11

經過一天的搜索,我有工作的解決方案。一切都在你如何開始節點。因此,首先,做平常:更具體地說

java -jar lib/selenium-server-standalone-2.20.0.jar -role webdriver -hub http://localhost:4444/grid/register -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=5 -Dwebdriver.chrome.driver=lib\chromedriver.exe 

java -jar lib/selenium-server-standalone-2.20.0.jar -role hub 

然後開始像這樣的節點,您必須使用參數browser啓動的節點,然後添加-D參數中指定的完整路徑在ChromeDriver

我巨大的感謝送給約翰Naegle誰在這裏SO關於Internet Explorer的回答類似的問題 - 看here

+0

非常感謝解決方案,經過一個晚上試圖讓它工作。對於Linux(Centos),您需要使用chromedriver和chrome安裝。這也花了我一段時間來找出:( – 2012-10-17 09:58:32

1

這很有趣,但webdriver的無法解析的DNS,http://localhost:4444/ 我編輯我的主機文件,取消註釋行:

127.0.0.1本地主機

它完成。

相關問題