1

I'am trying to run a simple code from hub to node, hub and node connections are successful.

While executing the program I am getting the exception

org.openqa.selenium.SessionNotCreatedException

Chrome driver path which I have mentioned is a share path that can be accessible from the node machine.

  • Chrome Version: 58.0.3029.110
  • Chrome Driver Version: 2.9

Both Hub and Node are remote machines.

Below is the code used:

public static void main(String[] args) throws MalformedURLException {

    WebDriver driver;
    System.setProperty("webdriver.chrome.driver", "Q:\\xxxxx\\chromedriver.exe");
    DesiredCapabilities dc = new DesiredCapabilities();
    dc.setBrowserName("chrome");
    dc.setPlatform(Platform.VISTA);
    driver = new RemoteWebDriver(new URL("http://10.xx.xxx.xx:5566/wd/hub"), dc); //node url
    driver.get("https://www.google.com");

}

Below is the console message:

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, platform=VISTA}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'A5DAFC-W7A-0012', ip: '10.xx.xxx.xx', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
    at testcases.Grid.main(Grid.java:23)
try-catch-finally
  • 7,436
  • 6
  • 46
  • 67
Vinoth Vasu
  • 53
  • 1
  • 1
  • 6
  • The error `SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, platform=VISTA}]` says it all. Can you share the commands you used to start the Hub & Node? Thanks – undetected Selenium Jul 14 '17 at 07:21
  • 1
    Sure thanks for the reply. Hub command: java -jar selenium-server-standalone-3.4.0.jar -role hub -port 4123 Node Command: java -jar selenium-server-standalone-3.4.0.jar -role webdriver -hub http://10.xx.xxx.xx:4123/grid/register -port 5566 – Vinoth Vasu Jul 14 '17 at 08:54
  • The `System.setProperty()` call is superfluous when connecting to a hub using the `RemoteWebDriver`. – try-catch-finally Jul 14 '17 at 20:48

2 Answers2

1

Here is the Answer to your Question:

As you have used the following command to start the Selenium Grid Hub:

 java -jar selenium-server-standalone-3.4.0.jar -role hub -port 4123

To execute your code block through chromedriver.exe and Google Chrome Browser you can consider to start the Selenium Grid Node on port 5566 through this command:

java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-3.4.0.jar -role node -hub http://localhost:4123/grid/register -port 5566

Access the Selenium Grid Hub Console through <IP_of_GridHub>:4123/grid/console to see the Node being registered.

Let me know if this Answers your Question.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Go to environment variables, set system variable as "JAVA_HOME" C:\Program Files\Java\jdk1.8.0_301, this will rectify this issue.

Muhammad Dyas Yaskur
  • 6,914
  • 10
  • 48
  • 73