Issue
I want to run automatically selenium tests with gitlab-ci, docker.
Locally everything works fine, but it seems like, there are some connection issues with docker and selenium.
The job is failing with
selenium.test.dashboard.MyTest > myFirstTest FAILED
org.openqa.selenium.remote.UnreachableBrowserException
Caused by: java.net.ConnectException
Caused by: java.net.ConnectException
java.lang.NullPointerException
I tried to change different url's to connect to selenium server and I thought there is maybe a port issue. But every combination which I tried ended up with the same result.
.gitlab-ci.yml
image: gradle:alpine
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
stages:
- build
- seleniumTesting
build:
stage: build
script:
- echo $CI_JOB_STAGE
- echo $CI_COMMIT_REF_NAME
- gradle --build-cache war
artifacts:
paths:
- public
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
paths:
- build
- .gradle
seleniumTestingChrome:
stage: seleniumTesting
script: gradle integrationTest
# services:
# - selenium/standalone-chrome:latest
services:
- name: selenium/standalone-chrome:latest
artifacts:
paths:
- build/reports/tests/
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
paths:
- build
- .gradle
Java code for RemoteWebDriver
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
try {
// driver = new RemoteWebDriver( new URL("http://selenium_standalone-chrome:4444/wd/hub"), capabilities);
WebDriver driver = new RemoteWebDriver( new URL("http://127.0.0.1:4444/wd/hub"), capabilities);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
created container on runner
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
92f018da4cbe 8017d8c2ba74 "sh -c 'if [ -x /usr…" 20 seconds ago Up 19 seconds runner-Y2QWpCBd-project-4-concurrent-0-build-4
9dfdc838a7af 9e599fb82f84 "/opt/bin/entry_poin…" 40 seconds ago Up 38 seconds 4444/tcp runner-Y2QWpCBd-project-4-concurrent-0-selenium__standalone-chrome-0
docker logs command on runner
019-08-30 17:06:02,099 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
2019-08-30 17:06:02,101 INFO supervisord started with pid 7
2019-08-30 17:06:03,106 INFO spawned: 'xvfb' with pid 10
2019-08-30 17:06:03,109 INFO spawned: 'selenium-standalone' with pid 11
17:06:03.826 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
2019-08-30 17:06:03,830 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2019-08-30 17:06:03,830 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
17:06:04.065 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2019-08-30 17:06:04.200:INFO::main: Logging initialized @1058ms to org.seleniumhq.jetty9.util.log.StdErrLog
17:06:04.804 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
17:06:05.050 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
I do expect that the test is running on the gitlab-ci-runner in a docker container. Connects to the selenium-server and executes the selenium test with a public available url
Solution
As pointed out by @Sascha Frinken
The URL to connect to the RemoteWebDriver was wrong. I missed one underscore.
"http://selenium_standalone-chrome:4444/wd/hub"
VS
"http://selenium__standalone-chrome:4444/wd/hub"
Answered By - Jens H
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.