Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium: http://localhost:4444/wd/hub returns a NullPointerException, what am I doing incorrectly

Given: Attempting to use a RemoteWebDriver in C# with this code.

var url = new Uri("http://localhost:4444/wd/hub");
var wd = new RemoteWebDriver(url, DesiredCapabilities.Chrome());

The new RemoteWebDriver code above doesn't respond until there's a timeout...

More Details

I've started my Hub with these parameters to the Selenium Server:

-jar "C:\SomeFolder\selenium-server-standalone-3.0.1.jar" -port 4444 -role hub

And registered a Node using these parms..

-jar "C:\SomeFolder\selenium-server-standalone-3.0.1.jar" -role node -hub http://localhost:4444/grid/register -port 9662 

Debugging

If I type in this URL after starting the Hub, It shows there is a registered Node:

http://location:4444/grid/console

But when typing in this url after starting the Hub

http://localhost:4444/wd/hub

The browser shows this java (json) stack trace pointing to ExternalSessionKey.java

{"status":13,"value":{"class":"java.lang.NullPointerException","stackTrace":[{"fileName":"ExternalSessionKey.java","className":"org.openqa.grid.internal.ExternalSessionKey","methodName":"fromWebDriverRequest","lineNumber":77},{"fileName":"WebDriverRequest.java","className":"org.openqa.grid.web.servlet.handler.WebDriverRequest","methodName":"extractSession","lineNumber":62},{"fileName":"RequestHandler.java","className":"org.openqa.grid.web.servlet.handler.RequestHandler","methodName":"getSession","lineNumber":231},{"fileName":"RequestHandler.java","className":"org.openqa.grid.web.servlet.handler.RequestHandler","methodName":"process","lineNumber":118},{"fileName":"DriverServlet.java","className":"org.openqa.grid.web.servlet.DriverServlet","methodName":"process","lineNumber":83},{"fileName":"DriverServlet.java","className":"org.openqa.grid.web.servlet.DriverServlet","methodName":"doGet","lineNumber":61},{"fileName":"HttpServlet.java","className":"javax.servlet.http.HttpServlet","methodName":"service","lineNumber":687},{"fileName":"HttpServlet.java","className":"javax.servlet.http.HttpServlet","methodName":"service","lineNumber":790},{"fileName":"ServletHolder.java","className":"org.seleniumhq.jetty9.servlet.ServletHolder","methodName":"handle","lineNumber":808},{"fileName":"ServletHandler.java","className":"org.seleniumhq.jetty9.servlet.ServletHandler","methodName":"doHandle","lineNumber":587},{"fileName":"SessionHandler.java","className":"org.seleniumhq.jetty9.server.session.SessionHandler","methodName":"doHandle","lineNumber":221},{"fileName":"ContextHandler.java","className":"org.seleniumhq.jetty9.server.handler.ContextHandler","methodName":"doHandle","lineNumber":1127},{"fileName":"ServletHandler.java","className":"org.seleniumhq.jetty9.servlet.ServletHandler","methodName":"doScope","lineNumber":515},{"fileName":"SessionHandler.java","className":"org.seleniumhq.jetty9.server.session.SessionHandler","methodName":"doScope","lineNumber":185},{"fileName":"ContextHandler.java","className":"org.seleniumhq.jetty9.server.handler.ContextHandler","methodName":"doScope","lineNumber":1061},{"fileName":"ScopedHandler.java","className":"org.seleniumhq.jetty9.server.handler.ScopedHandler","methodName":"handle","lineNumber":141},{"fileName":"HandlerWrapper.java","className":"org.seleniumhq.jetty9.server.handler.HandlerWrapper","methodName":"handle","lineNumber":97},{"fileName":"Server.java","className":"org.seleniumhq.jetty9.server.Server","methodName":"handle","lineNumber":499},{"fileName":"HttpChannel.java","className":"org.seleniumhq.jetty9.server.HttpChannel","methodName":"handle","lineNumber":310},{"fileName":"HttpConnection.java","className":"org.seleniumhq.jetty9.server.HttpConnection","methodName":"onFillable","lineNumber":257},{"fileName":"AbstractConnection.java","className":"org.seleniumhq.jetty9.io.AbstractConnection$2","methodName":"run","lineNumber":540},{"fileName":"QueuedThreadPool.java","className":"org.seleniumhq.jetty9.util.thread.QueuedThreadPool","methodName":"runJob","lineNumber":635},{"fileName":"QueuedThreadPool.java","className":"org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3","methodName":"run","lineNumber":555},{"className":"java.lang.Thread","methodName":"run","lineNumber":-1}]}}

Can anyone interpret the Stack Trace for me, and what to do to get this working?

Thanks!

like image 670
JWP Avatar asked Jan 16 '17 18:01

JWP


People also ask

What is localhost 4444 WD hub?

The URL http://localhost:4444/wd/hub is designed such that it expects a PAYLOAD with your operation. Since you haven't provided the desired payload you are seeing a NullPointerException. This URL is not supposed to be opened up in a browser.

What is the Selenium Grid?

What is Selenium Grid? Selenium Grid is a smart proxy server that makes it easy to run tests in parallel on multiple machines. This is done by routing commands to remote web browser instances, where one server acts as the hub. This hub routes test commands that are in JSON format to multiple registered Grid nodes.


1 Answers

There is nothing wrong at your end.

The URL http://localhost:4444/wd/hub is designed such that it expects a PAYLOAD with your operation. Since you haven't provided the desired payload you are seeing a NullPointerException.

This URL is not supposed to be opened up in a browser. Its meant to be consumed via Http operations with a proper payload that adheres to the Selenium w3c spec

like image 126
Krishnan Mahadevan Avatar answered Sep 20 '22 07:09

Krishnan Mahadevan