1

I am getting org.openqa.selenium.SessionNotCreatedException exception when trying to create driver through Selenium standalone jar 3.14.

I have used below commands to start hub and node

1) java -jar selenium-server-standalone-3.141.59.jar -role hub

2) java -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.xxx.xx.xxx:4444/grid/register -port 5556 -browser browserName=chrome,maxInstance=3 -browser browserName=firefox,maxInstance=3

Trying to create driver through below code

System.setProperty("webdriver.gecko.driver",
System.getProperty("user.dir") + "/drivers/" +"geckodriver");
DesiredCapabilities caps = DesiredCapabilities.firefox();
caps.setBrowserName("firefox");
caps.setPlatform(Platform.LINUX);
caps.setVersion("64.0");
driver = new RemoteWebDriver(new URL("http://192.xxx.xx.xxx:4444/wd/hub"),caps);

I am getting below exception:

org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=firefox, moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}, platform=LINUX}], required capabilities = Capabilities [{}]
Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000'
System info: host: 'HP-ProBook-440-G5', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-43-generic', java.version: '1.8.0_181'
Driver info: driver.version: RemoteWebDriver
 at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
 at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
 at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:158)
 at com.jio.web.base.TestBase.initDriver(TestBase.java:290)
 at com.jio.web.base.Setup.assignDriver(Setup.java:54)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
 at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
 at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
 at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
 at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:178)
 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
 at org.testng.TestRunner.privateRun(TestRunner.java:782)
 at org.testng.TestRunner.run(TestRunner.java:632)
 at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
 at org.testng.SuiteRunner.run(SuiteRunner.java:268)
 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
 at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
 at org.testng.TestNG.run(TestNG.java:1064)
 at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
undetected Selenium
194k44 gold badges303 silver badges385 bronze badges
asked Jan 15, 2019 at 10:38
1
  • Only exception won't help us as it is a part of the error which you have mis-configured. You need to provide us the version info programatically (preferably through CLI) Commented Jan 15, 2019 at 12:24

1 Answer 1

1

As your Selenium Grid Node is using geckodriver to communicate with the Selenium Grid Hub, so you need to initiate the Selenium Grid Node with the absolute location of the geckodriver as follows:

java -Dwebdriver.gecko.driver=/path/to/geckodriver -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.xxx.xx.xxx:4444/grid/register -port 5556 -browser browserName=chrome,maxInstance=3 -browser browserName=firefox,maxInstance=3
answered Jan 15, 2019 at 10:54
4
  • 1
    I tried this also but still getting same issue org.openqa.selenium.SessionNotCreatedException: Error forwarding the new session cannot find : Capabilities {browserName: firefox, marionette: true, platform: LINUX, version: 64.0} Commented Jan 15, 2019 at 11:06
  • Update the question with browserName, platform and version information along with the commands you have used to start the Hub and Node Commented Jan 15, 2019 at 11:38
  • if Suppose there are 20 node then do we have to pass the path of gecko.driver on each node ? I have a scenario where I have to execute the test case on IE,FF, Chrome of each node from selenium hub ? Commented Feb 10, 2020 at 8:13
  • @jitendragupta You can pass multiple variants of WebDriver. Commented Feb 10, 2020 at 8:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.