Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Grid does not run Chrome on another computer

I have this problem. When on different computer, I start HUB and NODE and then run my tests where I initialize Google Chrome like this:

 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);

Everything runs ok on my computer - Chrome comes up and does the script. However, If my friend tries to do exactly the same, she gets this error:

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

So far only difference what I found is, that hers hub is listening on http://10.10.190.134:5555 mine is listening on http://10.131.7.44:5555 but both can access the console on same IP and port. I dont have any clue whats wrong. Everything is appreciated, thanks

** EDIT **

Iried to run it on another computer and I had the same error. Little debugging showed me this message:

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

So, prior setting up the Chrome in Selenium Grid, I need to do this:

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

I tried to do it and stil unable to run the Chrome... Any help is still wanted

EDID2 This is how I exactly set the property:

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

I am using this approach because I need to run it on more computer and the JAR file can have different locations.

BTW, the warning is found in window with Selenium Grid in role node. I am thinking, if there is any other switcher. So far I am running these commands:

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?
like image 463
Pavel Janicek Avatar asked Apr 04 '12 08:04

Pavel Janicek


2 Answers

After a day searching, I have working solution. Everything is in how do you start the node. So first, do the usual:

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

Then start the node like this:

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 

More specifically: You have to start up the NODE with parameter browser and add -D parameter specifying the full path to the ChromeDriver

My huge thanks goes to John Naegle who answered similar question here on SO regarding the Internet Explorer - see here

like image 109
Pavel Janicek Avatar answered Jan 01 '23 09:01

Pavel Janicek


That's funny, but webdriver cannot resolve dns, http://localhost:4444/ I edited my host file, uncommented line:

127.0.0.1 localhost

And It's done.

like image 23
Dimmduh Avatar answered Jan 01 '23 09:01

Dimmduh