I am implementing selenium grid and the capability to launch the tests using the RemoteWebDriver. I am using docker standalone image. Below is my code
public void setUp() throws MalformedURLException {
ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox");
options.addArguments("--headless");
options.addArguments("--disable-dev-shm-usage");
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444"),options);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
driver.get("www.google.com");
driver.manage().window().maximize();
}
Command:
docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome:latest
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1f810511cbe2 selenium/standalone-chrome:latest "/opt/bin/entry_poin…" 9 seconds ago Up 7 seconds 0.0.0.0:4444-\>4444/tcp, 0.0.0.0:7900-\>7900/tcp, 5900/tcp modest_keller
I have also added selenium-java, selenium-manager and testing dependencies in pom.xml. I am using:
- Java 11
- Selenium 4.8.0
- Selenium Manager 4.8.0
- Chrome version 109.0.5414.119
- IDE IntelliJ
- MacOS
I am getting below errors:
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Unable to parse remote response: var json = Object.freeze('{"consoleLink": "\\u002fgrid\\u002fconsole","type": "Grid Hub","class": "org.openqa.grid.web.servlet.DisplayHelpHandler$DisplayHelpServletConfig","version": "3.141.59"}');
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:134)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:106)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:229)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at baseTest.BaseTest.setUp(BaseTest.java:30)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:69)
at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:361)
at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:296)
at org.testng.internal.invokers.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:180)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:122)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.testng.TestRunner.privateRun(TestRunner.java:829)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:437)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:431)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:391)
at org.testng.SuiteRunner.run(SuiteRunner.java:330)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
at org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng.TestNG.run(TestNG.java:1067)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
Caused by: org.openqa.selenium.json.JsonException: Unable to parse: \<!DOCTYPE html\>
at org.openqa.selenium.json.Json.toType(Json.java:57)
at org.openqa.selenium.json.Json.toType(Json.java:50)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:131)
... 34 more
Caused by: org.openqa.selenium.json.JsonException: Unable to determine type from: <. Last 1 characters read: <
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.1', java.version: '11.0.17'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.json.JsonInput.peek(JsonInput.java:126)
at org.openqa.selenium.json.JsonTypeCoercer.lambda$buildCoercer$6(JsonTypeCoercer.java:141)
at org.openqa.selenium.json.JsonTypeCoercer.coerce(JsonTypeCoercer.java:127)
at org.openqa.selenium.json.Json.toType(Json.java:71)
at org.openqa.selenium.json.Json.toType(Json.java:55)
... 36 more