Selenium独立服务器的实例,该节点返回在com.google.gson.JsonPrimitive.isPrimitiveOrString
处引发的500错误响应NullPointerException解决此错误的任何提示都是相关的。
启动Selenium Server Hub和Node 检查节点是否列在服务器控制台上。
软件版本:
服务器启动命令:
java -jar "selenium-server-standalone-3.5.0.jar" -role hub
java -Dwebdriver.gecko.driver="C:/selenium/geckodriver.exe" -jar "selenium-server-standalone-3.5.0.jar" -role node -hub http://localhost:4444/grid/register
Maven POM:
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
Java Class(不包括导入):
public class GoogleSearchTest extends TestCase {
public void testApp() throws MalformedURLException {
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setPlatform(Platform.ANY);
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), cap);
driver.navigate().to("http://www.google.com/");
} }
错误堆栈:
Problem accessing /wd/hub/session. Reason:
Caused by: 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)
此错误似乎在自动化测试的早期发生。问题我还没有答案:发送的JSON有效负载是什么,是否需要配置其他功能。
类似的帖子