I am running the gitlab CI with selenoid and chrome docker images.
First I developed the docker-compose.yml with images: “aerokube/selenoid:latest”, “aerokube/selenoid-ui:latest” and “selenoid/vnc_chrome:90.0”. And run the test on docker locally. It’s passed. Below is the test part which related to the remote url setup for the test runned locally.
@BeforeSuite
fun setup() {
Configuration.driverManagerEnabled = false
Configuration.remote = "http://localhost:4444/wd/hub"
Configuration.baseUrl = "https://www.google.com/"
//System.setProperty("selenide.browser", "chrome")
Configuration.browser = "chrome"
Configuration.browserVersion = "90.0"
//Configuration.browserSize = "1920x1080"
Configuration.startMaximized
val capabilities = DesiredCapabilities()
Configuration.browserCapabilities = capabilities
capabilities.setCapability("enableVNC", true)
capabilities.setCapability("enableVideo", true)
@Test
fun logIn() {
open("https://www.google.com/")
Then I wrote a gitlab-ci.yml file and wanted to run it on Gitlab CI with gitlab runner.
The gitlab-ci.yml file is this:
image: gradle:jdk11
stages:
- gradle-build
- docker-test
.gradle_template: &gradle_definition
variables:
GRADLE_OPTS: “-Dorg.gradle.daemon=false”
before_script:
- export GRADLE_USER_HOME=${CI_PROJECT_DIR}/.gradle
gradle-build:
<<: gradle_definition
stage: gradle-build
script:
- chmod +x ./gradlew
- ./gradlew --build-cache assemble
cache:
key: “$CI_COMMIT_REF_NAME”
paths: - build
- .gradle
artifacts:
paths: -
build/libs/ .jar
expire_in: 1 hour
only: - feature/edit_section
docker-test:
stage: docker-test
image:
name: docker/compose:1.29.2
entrypoint: [ “/bin/sh”, “-c” ]
services:
- docker:19.03.12-dind
variables:
DOCKER_TLS_CERTDIR: “”
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
cache:
key: “$CI_COMMIT_REF_NAME”
policy: pull
paths: - build
- .gradle
dependencies: - gradle-build
before_script: - docker info
- docker-compose --version
script: - apk add --no-cache docker-compose
- apk add openjdk11
- docker network create selenoid
- docker-compose down
- docker-compose up --build --force-recreate --no-deps -d
- docker network inspect selenoid
- echo “Hello, UI-test”
- chmod +x ./gradlew
- ./gradlew :test --tests “com.UItest.ManageProject”
only: - feature/edit_section
after_script:
- echo “End CI”
But when I run the test. It failed. The error is:
Gradle suite > Gradle test > com.UItest.ManageProject > logIn FAILED
59 org.openqa.selenium.remote.UnreachableBrowserException at ManageProject.kt:46
60 Caused by: java.net.ConnectException at ManageProject.kt:46
61 Caused by: java.net.ConnectException at ManageProject.kt:46
I thought it’s because the reason should be on the remote URL. Then I tried to change the remote url as those below, but still failed.
Configuration.remote = "http://selenoid__vnc-chrome:4444/wd/hub"
Configuration.remote = "http://selenoid-chrome:4444/wd/hub"
Configuration.remote = "http://selenoid:4444/wd/hub"
The error is:
Gradle suite > Gradle test > com.UItest.ManageProject > logIn FAILED
org.openqa.selenium.remote.UnreachableBrowserException at ManageProject.kt:46
Caused by: java.net.UnknownHostException at ManageProject.kt:46
Dose anyone know the reasons and help me? If you need more details, please tell me. Thanks in advance.