I am executing the Selenium tests usinng TestNG on selenium standalone chrome debug docker container.
Below is the Selenium code to instantiate remote web driver:
ChromeOptions co = new ChromeOptions();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4445"), co);
Below is the docker code to start the container:
docker run --name chromecontainer -d -p 4445:4444 -p 5901:5900 --shm-size="2g" selenium/standalone-chrome-debug:latest
It is skipping the test and throwing the below error:
FAILED CONFIGURATION: @BeforeMethod bmeth(org.testng.TestRunner@fcdb78, org.testng.xml.XmlTest@769036db, public void testing.TC_005.vabc() throws java.lang.Exception, [], [TestResult name={null} status=CREATED method=TC_005.vabc()[pri:0, instance:testing.TC_005@1e3708] output={null}])
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Unable to parse remote response: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="/assets/displayhelpservlet.css" media="all"/>
<link href="/assets/favicon.ico" rel="icon" type="image/x-icon" />
<script src="/assets/jquery-3.1.1.min.js" type="text/javascript"></script>
<script src="/assets/displayhelpservlet.js" type="text/javascript"></script>
<script type="text/javascript">
var json = Object.freeze('{"consoleLink": "\u002fwd\u002fhub","type": "Standalone","class": "org.openqa.grid.web.servlet.DisplayHelpHandler$DisplayHelpServletConfig","version": "3.141.59"}');
</script>
</head>
<body>
Caused by: org.openqa.selenium.json.JsonException: Unable to parse: <!DOCTYPE html>
Caused by: org.openqa.selenium.json.JsonException: Unable to determine type from: <. Last 1 characters read: <
But if I add /wd/hub
in the remote url, then the test is running fine.
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4445/wd/hub"), co);
I tried to search the reason for it, but could not find.
Can anyone please explain why it is throwing the error if we do not add /wd/hub, because as per Selenium doc https://github.com/SeleniumHQ/docker-selenium#quick-start, it mentions that it is no longer required ?
CodePudding user response:
I just looked at selenium/standalone-chrome-debug:latest layer #16 and there is the following command:
RUN /bin/sh -c mkdir -p /opt/selenium /var/run/supervisor /var/log/supervisor && touch /opt/selenium/config.json && chmod -R 777 /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd && wget --no-verbose https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar -O /opt/selenium/selenium-server-standalone.jar && chgrp -R 0 /opt/selenium ${HOME} /var/run/supervisor /var/log/supervisor && chmod -R g=u /opt/selenium ${HOME} /var/run/supervisor /var/log/supervisor # buildkit
So it looks like there is Grid 3 under the hood so you have to add /wd/hub
which becomes optional in Grid 4.