作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Selenium 的新手并开始学习它。但是 Selenium Grid 不适合我。使用的服务器版本是 selenium-server-standalone-3.14.0.jar。使用命令,集线器和节点正在运行。
将节点添加到集线器的代码是使用 Eclipse 中的 TestNG 编写的。代码如下:
ChromeOptions options = new ChromeOptions();
options.setCapability(CapabilityType.PLATFORM_NAME, Platform.WIN10);
options.setCapability(CapabilityType.BROWSER_NAME, "chrome");
driver = new RemoteWebDriver(new URL("http://192.xxx.x.xx:48807/wd/hub"), options); driver.get("https://www.amazon.in/");
org.openqa.selenium.WebDriverException: Unable to parse remote response:
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:111)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)
at grid.Node2.f(Node2.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:580)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:40)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:489)
at org.testng.internal.thread.ThreadUtil$1.call(ThreadUtil.java:52)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.openqa.selenium.json.JsonException: Expected to read a START_MAP but instead have: END. Last 0 characters read:
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-
java -jar selenium-server-standalone-3.14.0.jar -role hub
最佳答案
对错误有点惊讶:
org.openqa.selenium.json.JsonException: Expected to read a START_MAP but instead have: END. Last 0 characters read
Cannot coerce something that is not a number to a number: " + type
PLATFORM_NAME
不是有效配置,您需要将其更改为
PLATFORM
.
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
public class testChromeOnGrid_test
{
@Test
public void test1() throws MalformedURLException
{
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setCapability(CapabilityType.PLATFORM, Platform.WIN8);
options.setCapability(CapabilityType.BROWSER_NAME, "chrome");
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
driver.get("http://google.com/");
System.out.println("Title is : "+driver.getTitle());
driver.quit();
}
}
[RemoteTestNG] detected TestNG version 6.14.2
Oct 16, 2018 3:00:57 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Title is : Google
PASSED: test1
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================
>java -DWebdriver.chrome.driver=C:\\path\\to\\chromedriver.exe -jar selenium-server-standalone-3.14.0.jar -role node -hub http://<IP_GRID_HUB>:4444/grid/register/
关于selenium - org.openqa.selenium.json.JsonException : Expected to read a START_MAP but instead have: END. 通过 Node 执行测试时读取的最后 0 个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52830236/
我是 Selenium 的新手并开始学习它。但是 Selenium Grid 不适合我。使用的服务器版本是 selenium-server-standalone-3.14.0.jar。使用命令,集线器
我是一名优秀的程序员,十分优秀!