Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to create new remote session - Selenium webdriver

I am getting exception

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, version=48.0.1, platform=ANY}], required capabilities = Capabilities [{}]' while trying to run selenium script in a remote web driver.

Hub and node are configured properly and its able to communicate to each other.

  • Selenium web driver : 3.0
  • Platform : Windows server 2012 R2.
  • Firefox Version: 48.0.1

Code used in my script :

       System.setProperty("webdriver.gecko.driver", "mypath/geckodriver.exe");
     DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
     capabilities.setCapability("marionette", true);
     capabilities.setBrowserName("firefox");
     capabilities.setPlatform(Platform.ANY);

     RemoteWebDriver driver =new RemoteWebDriver(new URL("http://ipofthenode:4444/wd/hub"), capabilities);

     driver.get("http://stackoverflow.com");

     System.out.println("executed");

Detailed stack trace:

an 19, 2017 6:07:36 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end Jan 19, 2017 6:07:37 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Falling back to original OSS JSON Wire Protocol. Jan 19, 2017 6:07:37 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Falling back to straight W3C remote end connection Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, version=48.0.1, platform=ANY}], required capabilities = Capabilities [{}] Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:16 -0700' System info: host: 'Hostname', ip: 'IP', os.name: 'Windows Server 2012 R2', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_101' 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.(RemoteWebDriver.java:128) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:155) at demo.Grid.main(Grid.java:26)

like image 549
Sona Shetty Avatar asked Jan 19 '17 07:01

Sona Shetty


1 Answers

Create a .bat file adding below command

C:\Selenium_Grid
start java -Dwebdriver.gecko.driver=C:\Selenium_Grid\geckodriver\geckodriver.exe -jar C:\Selenium_Grid\selenium-server-standalone-3.0.1.jar -role node -hub http://localhost:4444/grid/register -browser browserName=firefox -port 5555

(replace paths with yours)

then start the .bat file before executing your code

like image 69
mohamed faisal Avatar answered Oct 24 '22 21:10

mohamed faisal