I am running selenium test in Gitlab CI, but have problem with setting remote URL correctly when using the gitlab runner instead of my computer.
The IP address of the runner is 192.168.xxx.xxx
. And when I run the pipeline, I got the IP address of selenium hub is 172.19.0.2/16
. I tried both, and both failed. I also tried to use the name of the selenium hub container http://selenium__hub
, but it also failed.
The docker-compose.yml is:
version: "3"
services:
chrome:
image: selenium/node-chrome:4.0.0-20211013
container_name: chrome
shm_size: 2gb
depends_on:
- selenium-hub
volumes:
- ./target:/home/seluser/Downloads
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_GRID_URL=http://localhost:4444
ports:
- "6900:5900"
edge:
image: selenium/node-edge:4.0.0-20211013
container_name: edge
shm_size: 2gb
depends_on:
- selenium-hub
volumes:
- ./target:/home/seluser/Downloads
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_GRID_URL=http://localhost:4444
ports:
- "6901:5900"
firefox:
image: selenium/node-firefox:4.0.0-20211013
container_name: firefox
shm_size: 2gb
depends_on:
- selenium-hub
volumes:
- ./target:/home/seluser/Downloads
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_GRID_URL=http://localhost:4444
ports:
- "6902:5900"
selenium-hub:
image: selenium/hub:4.0.0-20211013
container_name: selenium-hub
ports:
- "4444:4444"
the gitlab runner's config file looks like this:
[[runners]]
name = "selenium"
url = "https://gitlab.myhost.at"
token = "xxxxxxxx"
executor = "docker"
privileged = true
links = ["selenium__hub:hub"]
[runners.docker]
image = "docker:stable"
privileged = true
The remote url I have tried are:
WebDriver driver = new RemoteWebDriver(new URL("http://192.168.xxx.xxx:4444/wd/hub"), cap);
WebDriver driver = new RemoteWebDriver(new URL("http://172.19.0.2:4444/wd/hub"), cap);
WebDriver driver = new RemoteWebDriver(new URL("http://selenium__hub:4444/wd/hub"), cap);
How can I get this to work with GitLab runner?