尝试在Angular应用程序上运行Protractor e2e测试时,我的WebDriver Manager会抛出NullPointerException。
这个问题不关于NullPointerException的问题。这是一个关于如何使量角器和端到端测试工作的问题。
我将我的设置与同事进行了比较,比较了环境变量,chrome版本等,它们都匹配。然而它适用于他,但我的开发盒立刻失败了。
通过比较我们的输出,失败的行是在寻找处理程序时。在我的同事系统上,控制台输出是:
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}
但是在我的开发盒上,此时我得到以下内容:
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)
对问题可能是什么的任何想法?
答案 0 :(得分:0)
好的,让它工作,并将发布,以防其他任何人遇到这个。量角器在特定目录中查找chrome,因此您需要确保在那里有chrome可执行文件。 Chrome的版本也很重要,因为安装的Chrome驱动程序仅适用于特定版本的Chrome,如果存在不匹配,那么您将会遇到这样的问题。因此,请检查您的Chrome版本,然后检查Chrome驱动程序版本并确保它们可以协同工作。 Chrome驱动程序下载页面提供兼容性信息。不同版本的Protractor将为您提供不同版本的chrome驱动程序,因此在升级时也需要注意这一点。