Search code examples
pythonseleniumselenium-webdriverselenium-chromedriverselenium-grid

SessionNotCreatedException: Message: Unable to create new service: ChromeDriverService with ChromeDriver and SeleniumGrid through Python


Hi anyone know what is going on or how I can debug the error as following. the step I did is using setup hub command and register node to hub. after the command register node. I can see the log as

The node is registered to the hub and ready to use 

However when I run the test script I have error print up as:

selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create new service: ChromeDriverService

Binary versions:

  • selenium standalone version: 3.14.0
  • selenium remote driver version: selenium==3.14.1
  • python version: 3.6.4

Script:

import os
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

driver = webdriver.Remote(command_executor='http://localhost:4444/wd/hub',
                          desired_capabilities=DesiredCapabilities.CHROME)

Setup hub:

#java -jar /Users/admin/selenium-server-standalone-3.14.0.jar -host localhost -role hub

Register node:

#java -jar /Users/admin/selenium-server-standalone-3.14.0.jar -role node

Error:

E       selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create new service: ChromeDriverService
E       Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
E       Driver info: driver.version: unknown
E       Stacktrace:
E           at org.openqa.selenium.remote.server.ServicedSession$Factory.lambda$get$0 (ServicedSession.java:134)
E           at org.openqa.selenium.remote.server.ServicedSession$Factory.apply (ServicedSession.java:151)
E           at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$12 (ActiveSessionFactory.java:177)
E           at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:193)
...
E           at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
E           at java.util.concurrent.FutureTask.run (FutureTask.java:266)
E           at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
E           at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
E           at java.lang.Thread.run (Thread.java:745)

../lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py:242: SessionNotCreatedException

Solution

  • This error message...

    selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create new service: ChromeDriverService
    

    ...implies that the ChromeDriver was unable to initiate/spawn a new ChromeDriverService.

    There are a couple of issues in the commands and incompatibility between the version of the binaries you are using as follows:

    • Your JDK version is 1.8.0_91 which is pretty ancient.
    • Upgrade JDK to recent levels JDK 8u181.
    • To register a Selenium Grid Hub you need to use the following command:

      >java -jar /Users/admin/selenium-server-standalone-3.14.0.jar -role hub
      
    • To register a Selenium Grid Node for ChromeDriver and Chrome you need to pass the absolute path of the ChromeDriver along with the Key and Value of the Registration URI as follows:

      >java -Dwebdriver.chrome.driver=/path/to/chromedriver.exe -jar /Users/admin/selenium-server-standalone-3.14.0.jar -role node -hub http://<IP_GRID_HUB>:4444/grid/register
      
    • You code block looks good to me.