Testing with chrome and RemoteWebdriver

6,851 views
Skip to first unread message

gilbertf

unread,
May 13, 2014, 3:14:42 PM5/13/14
to seleniu...@googlegroups.com
I am trying to execute a test with chromedriver, and it does not launch.

I have setup my Eclipse environment to start a local selenium standalone server with these parameters:
-jar selenium-server-standalone-2.41.0.jar  -Dwebdriver.chrome.driver=C:\Webdriver\chromedriver.exe

My test code is this:

public class TestClass {
   
   
public static void main(String[] args) {
       
// Setup du test - création du driver avec les capacités nécessaires
       
       
DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
        desiredCapabilities
.setPlatform(Platform.WINDOWS);
       
try{
           
WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), desiredCapabilities);
            doTest
(driver, "http://testserver");
           
            driver
.quit();
       
}
       
catch(MalformedURLException e){}
           
   
}

   
public static void doTest(WebDriver driver, String baseUrl)
   
{
        driver
.get(baseUrl + "/testpage.jsp");
        driver
.findElement(By.id("h_1234395479221o3")).click();
        driver
.findElement(By.name("t_n1216757067133")).click();
   
}
   
}

If I change the DesiredCapabilities for firefox(), this works perfectly, but with chrome(), I get the following error in the server console:
14:52:45.143 INFO - Executing: [new session: Capabilities [{browserName=chrome}]] at URL: /session)
14:52:45.162 INFO - Creating a new session for Capabilities [{browserName=chrome}]
Starting ChromeDriver (v2.10.267521) on port 33609
Only local connections are allowed.
Port not available. Exiting...

How do I setup the server to accept "remote" sessions for Chrome?  I even tried accessing the server with a browser and starting a Chrome session in the web interface and the same error occurs.


Phani.B

unread,
May 13, 2014, 11:13:46 PM5/13/14
to seleniu...@googlegroups.com
Kill any chromedriver process that were running and see what happens.

gilbertf

unread,
May 14, 2014, 8:48:06 AM5/14/14
to seleniu...@googlegroups.com
I tried this morning with a fresh-booted computer and I get the same result.   Here is the complete log from the standalone server:

mai 14, 2014 8:41:41 AM org.openqa.grid.selenium.GridLauncher main
Infos: Launching a standalone server
Setting system property webdriver.chrome.driver to C:\Webdriver\chromedriver.exe
Setting system property webdriver.ie.driver to C:\Webdriver\IEDriverServer.exe
08:41:41.510 INFO - Java: Oracle Corporation 24.51-b03
08:41:41.511 INFO - OS: Windows 8 6.2 amd64
08:41:41.542 INFO - v2.41.0, with Core v2.41.0. Built from revision 3192d8a
08:41:42.120 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
08:41:42.122 INFO - Version Jetty/5.1.x
08:41:42.123 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
08:41:42.124 INFO - Started HttpContext[/selenium-server,/selenium-server]
08:41:42.124 INFO - Started HttpContext[/,/]
08:41:42.174 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@5f192118
08:41:42.175 INFO - Started HttpContext[/wd,/wd]
08:41:42.180 INFO - Started SocketListener on 0.0.0.0:4444
08:41:42.180 INFO - Started org.openqa.jetty.jetty.Server@4c7d5d85
08:41:59.595 INFO - Executing: [new session: Capabilities [{platform=WINDOWS, browserName=chrome, version=}]] at URL: /session)
08:41:59.615 INFO - Creating a new session for Capabilities [{platform=WINDOWS, browserName=chrome, version=}]
Starting ChromeDriver (v2.10.267521) on port 9348

Only local connections are allowed.
Port not available. Exiting...

I also tried starting chromedriver from the command line, and I get the same 2 error lines (the last two above).

gilbertf

unread,
May 14, 2014, 3:23:02 PM5/14/14
to seleniu...@googlegroups.com

I have resolved the problem! here is the explanation:

1) chromedriver ALWAYS gives the "Only local connections are allowed" message.  It means nothing if your test rig and chromedriver are on the same machine.  It is possible to add the "whitelisted-ips" option if you want to use chromedriver in a grid setup, which makes the message disappear.
2) I am running Windows 8.1 as a local administrator, but if the chromedriver executable is not in a local drive it cannot open ports.  I changed the real drive letter in my original post because I tought it had no impact; that was a mistake.

So, the solution is: move chromedriver.exe to the C: drive and suddenly it works.  There is probably some arcane Windows 8 sandboxing and/or network drive policy at work here, but I am not going into that.

On a side note: this solution also applies to the IEDriverServer.

Martyn Winsen

unread,
May 15, 2014, 1:11:22 PM5/15/14
to seleniu...@googlegroups.com
Hi Gilbert,
you mentioned that " It is possible to add the "whitelisted-ips" option if you want to use chromedriver in a grid setup, which makes the message disappear."

Can you elaborate on how you do that with Selenium Grid?
I can't see a way to send command-line options to the Chrome Driver when starting with the Selenium Hub or Node.

François-Léonard Gilbert

unread,
May 17, 2014, 1:00:56 PM5/17/14
to seleniu...@googlegroups.com

I didn't get that working, but there is a webdriver.chrome.args property you can set in java. This property is used to set the command line arguments.
The line should look like this:

DesiredCapabilities capabilities.setCapability("webdriver.chrome.args", Arrays.asList("--whitelisted-ips=127.0.0.1"));

> --
> You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/ZQ38CxvWN2w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
> To post to this group, send email to seleniu...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/cc81b937-4f05-486b-929d-84997e71b159%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages