-1

Whilst attempting to run Protractor e2e tests on an Angular Application, my WebDriver Manager is throwing a NullPointerException.

This question is not a question about NullPointerException. It is a question about how to get protractor and end to end tests working.

I've compared my setup with a co-worker, comparing environment variables, chrome version etc, and they all match. Yet it works on his, but immediately fails on my dev box.

By comparing our outputs, the failing line is when it is looking for a handler. On my colleagues system the console output is:

12:03:50.295 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@5b04c5b4
12:03:50.296 INFO - Handler thread for session 397d539330b46b88d3df3471e0cc30a6 (chrome): Executing POST on /session/397d539330b46b88d3df3471e0cc30a6/timeouts (handler: ServicedSession)
12:03:50.301 INFO - To upstream: {"type":"script","ms":30000}
12:03:50.305 INFO - To downstream: {"sessionId":"397d539330b46b88d3df3471e0cc30a6","status":0,"value":null}


However on my dev box, at this point I get the following:

2017-08-15 12:00:42.145:WARN:osjs.HttpChannel:qtp1227229563-14: /wd/hub/session
java.lang.NullPointerException
        at com.google.gson.JsonPrimitive.isPrimitiveOrString(JsonPrimitive.java:278)
        at com.google.gson.JsonPrimitive.setValue(JsonPrimitive.java:101)
        at com.google.gson.JsonPrimitive.<init>(JsonPrimitive.java:65)
        at org.openqa.selenium.remote.server.ExceptionHandler.lambda$execute$0(ExceptionHandler.java:82)
        at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source)
        at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
        at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
        at java.util.stream.ReferencePipeline.collect(Unknown Source)
        at org.openqa.selenium.remote.server.ExceptionHandler.execute(ExceptionHandler.java:88)
        at org.openqa.selenium.remote.server.WebDriverServlet.handle(WebDriverServlet.java:247)
        at org.openqa.selenium.remote.server.WebDriverServlet.doPost(WebDriverServlet.java:151)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at org.openqa.selenium.remote.server.WebDriverServlet.service(WebDriverServlet.java:111)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:841)
        at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:535)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.seleniumhq.jetty9.security.SecurityHandler.handle(SecurityHandler.java:548)
        at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
        at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
        at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:473)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
        at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.seleniumhq.jetty9.server.Server.handle(Server.java:564)
        at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:317)
        at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:251)
        at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
        at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:110)
        at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
        at org.seleniumhq.jetty9.util.thread.Invocable.invokePreferred(Invocable.java:128)
        at org.seleniumhq.jetty9.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
        at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
        at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
        at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
        at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
        at java.lang.Thread.run(Unknown Source)

Any thoughts on what the issue might be?

Mickey Puri
  • 835
  • 9
  • 18
  • @WilliamHampshire thanks, however selenium-webdriver comes as a dependency on protractor. I have uninstalled and reinstalled protractor a couple of times and not made any difference – Mickey Puri Aug 15 '17 at 13:35
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – JeffC Aug 17 '17 at 15:22
  • @JeffC afraid the NullPointerException is an effect and not the Cause. The question is how to get Protractor working and deal with errors that it is throwing. – Mickey Puri Aug 18 '17 at 10:32

1 Answers1

0

Ok, got it working, and will post in case anyone else runs into this. Protractor looks in a specific directory for chrome, so you need to ensure you have the chrome executable there. The version of Chrome is important too, as the Chrome Driver that gets installed only works with particular versions of Chrome, and if there is a mismatch, then you will get blow ups such as this. So check your Chrome Version and then the Chrome Driver version and ensure they can work together. the Chrome Driver download page gives compatibility info. Different versions of Protractor will get you different versions of the chrome driver, and so need to look out for that too in case you upgrade.

Mickey Puri
  • 835
  • 9
  • 18