[java] Setting Remote Webdriver to run tests in a remote computer using Java

I was trying to setup remote webdriver to run my tests in remote computer, as my application is deployed to my localhost. Using Selenium RC I used host address to run those tests and it worked fine; but I'm having trouble setting up the base class using remote webdriver. I've tried the following code but it has not worked. By the way, I had selenium tests which I am migrating to remote webdriver. I tried webdriver which works fine but couldn't setup the remote webdriver for remote execution. Any help will be appreciated.

public static  String base_url = "http://localhost:8084";     
Proxy proxy = new Proxy();     
proxy.setProxyAutoconfigUrl(base_url);
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(CapabilityType.PROXY, proxy);
RemoteWebDriver driver = new RemoteWebDriver(capabilities);
selenium = new WebDriverBackedSelenium(driver, base_url);

Sample grid 2 code which works for firefox but doesn't work on IE9

String hubURL = "http://myip:4444/wd/hub";
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
//capability.setBrowserName("internet explorer");
//capability.setPlatform("WINDOWS");
//capability.setVersion("9.0.4");
WebDriver driver = new RemoteWebDriver(new URL(hubURL), capability);
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("Cheese!");
element.submit();
driver.quit(); 

Error I was receiving when it's IE9 though I specified IE from command mode from node:

Exception in thread "main" org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : {platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}
Command duration or timeout: 110 milliseconds
Build info: version: '2.16.1', revision: '15405', time: '2012-01-05 12:23:11'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.38-13-generic', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:435)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:135)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:102)
at com.main.SelTest.main(SelTest.java:25)
Caused by: org.openqa.grid.common.exception.GridException: Error forwarding the new session cannot find : {platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}
at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:151)
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:81)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.openqa.jetty.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:473)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
at org.openqa.jetty.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)

This question is related to java selenium webdriver

The answer is


This is how I got rid of the error:

WebDriverException: Error forwarding the new session cannot find : {platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=11}

In your nodeconfig.json, the version must be a String, not an integer.

So instead of using "version": 11 use "version": "11" (note the double quotes).

A full example of a working nodecondig.json file for a RemoteWebDriver:

{
  "capabilities":
  [
    {
      "platform": "WIN8_1",
      "browserName": "internet explorer",
      "maxInstances": 1,
      "seleniumProtocol": "WebDriver"
      "version": "11"
    }
    ,{
      "platform": "WIN7",
      "browserName": "chrome",
      "maxInstances": 4,
      "seleniumProtocol": "WebDriver"
      "version": "40"
    }
    ,{
      "platform": "LINUX",
      "browserName": "firefox",
      "maxInstances": 4,
      "seleniumProtocol": "WebDriver"
      "version": "33"
    }
  ],
  "configuration":
  {
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "maxSession": 3,
    "port": 5555,
    "host": ip,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,
    "hubHost": {your-ip-address}
  }
}

By Default the InternetExplorerDriver listens on port "5555". Change your huburl to match that. you can look on the cmd box window to confirm.


  • First you need to create HubNode(Server) and start the HubNode(Server) from command Line/prompt using Java: -jar selenium-server-standalone-2.44.0.jar -role hub
  • Then bind the node/Client to this Hub using Hub machines IPAddress or Name with any port number >1024. For Node Machine for example: Java -jar selenium-server-standalone-2.44.0.jar -role webdriver -hub http://HubmachineIPAddress:4444/grid/register -port 5566

One more thing is that whenever we use Internet Explore or Google Chrome we need to set: System.setProperty("webdriver.ie.driver",path);


This issue came for me due to the fact that .. i was running server with selenium-server-standalone-2.32.0 and client registered with selenium-server-standalone-2.37.0 .. When i made both selenium-server-standalone-2.32.0 and ran then things worked fine


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to selenium

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81 session not created: This version of ChromeDriver only supports Chrome version 74 error with ChromeDriver Chrome using Selenium Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser Class has been compiled by a more recent version of the Java Environment How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium? How to make Firefox headless programmatically in Selenium with Python? element not interactable exception in selenium web automation Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click How do you fix the "element not interactable" exception?

Examples related to webdriver

WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click How do you fix the "element not interactable" exception? ImportError: No module named 'selenium' how to use List<WebElement> webdriver How to get attribute of element from Selenium? Selenium Finding elements by class name in python Open web in new tab Selenium + Python When running WebDriver with Chrome browser, getting message, "Only local connections are allowed" even though browser launches properly How can I start InternetExplorerDriver using Selenium WebDriver