Reputation: 41
I have set up a Selenium grid and selenium chrome node as docker continers and also created an container for my test suite. But once i try to run the test cases it is failing providing the below error message
org.openqa.selenium.remote.UnreachableBrowserException:
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:42:16'
System info: host: '267891a44849', ip: '172.17.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.184-linuxkit', java.version: '11.0.4'
Driver info: driver.version: RemoteWebDriver
Caused by: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:4444
Caused by: java.net.ConnectException: Connection refused (Connection refused)
created an docker image for my automation code through docker file
created an docker network
created an hub on docker using selenium grid
linked node to this hub
and tried to run the code
My Dockerfile to create image for automation code
FROM node AS chrome
USER root
WORKDIR /home/app
RUN apt-get install unzip && \
wget https://chromedriver.storage.googleapis.com/77.0.3865.40/chromedriver_linux64.zip && \
unzip chromedriver_linux64.zip && \
chmod +x /home/app/chromedriver
FROM maven:3.6.2-jdk-11-slim
COPY src /home/app/src
COPY pom.xml /home/app
COPY Dockerfile /home/app
WORKDIR /home/app
COPY --from=chrome /home/app/chromedriver /home/app
RUN chmod u+x chromedriver
ENTRYPOINT mvn clean test
Also I can see docker hub and node up for selenium
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e95780aac878 selenium/node-chrome "/opt/bin/entry_poin…" 29 hours ago Up 29 hours selenium-node
7e23e59006fb selenium/hub "/opt/bin/entry_poin…" 29 hours ago Up 29 hours 0.0.0.0:4446->4444/tcp selenium-hub
And my SetUp.java contians code as below
String nodeURL= "http://localhost:4446/wd/hub";
ChromeOptions remoteOptions = new ChromeOptions();
driver=new RemoteWebDriver(new URL(nodeURL), remoteOptions);
but on executing
$ docker run --rm -e SELENIUM_HUB=selenium-node --network grid <my automaiotn code image>
I am getting below error
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running Parallel01IT
inside after
Failed scenarios:
/home/app/src/test/java/features/NonRes.feature:49
1 Scenarios (1 failed)
3 Steps (1 failed, 2 skipped)
2m0.810s
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: '61da76b392d3', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.184-linuxkit', java.version: '1.8.0_212'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:566)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:132)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:145)
org.openqa.selenium.remote.UnreachableBrowserException:
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: '61da76b392d3', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.184-linuxkit', java.version: '1.8.0_212'
Driver info: driver.version: RemoteWebDriver
Caused by: java.net.SocketTimeoutException: connect timed out
But When I run the same test cases from my local [my laptop] on those docker selenium grid containers it is working fine However running the same test case as a docker container is failing.
Upvotes: 1
Views: 3991
Reputation: 1064
Run the chromedriver
with a headless
option. I have faced the same problem before and this resolved it.
chrome_options.add_argument("--headless")
Upvotes: 0