Can't make the yml file works with a private driver

Hello guys,

I’m trying to run test cases with selenium grid on the CI/CD. With this code it works fined

stages:

  • test

services:

  • docker:dind

variables:
DOCKER_HOST: tcp://docker:2375

pytest:
stage : test
image: python:3.7.9-alpine3.12
script:
- apk add --no-cache docker
- apk add --no-cache docker-compose
- ls
- docker-compose up -d
- pip3 install -r requirements.txt
- python --version
- python -m pytest test_pytest/AppPro/GUI/step_defs/test_login_logout.py

For information b = webdriver.Remote(command_executor=‘http://docker:4444/wd/hub’,)

But I can"t figured atout why it doesn’t work with this:

stages:

  • test

services:

  • docker:dind

.tags-default: &tags-default
tags:
- private_runner

pytest:
<<: *tags-default
stage : test
image: python:3.7.9-alpine3.12
script:
- apk add --no-cache docker
- apk add --no-cache docker-compose
- ls
- docker-compose up -d
- pip3 install -r requirements.txt
- python --version
- python -m pytest test_pytest/AppPro/GUI/step_defs/test_login_logout.py

Exception: HTTPConnectionPool(host=‘docker’, port=4444): Max retries exceeded with url: /session (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7f472bd10f10>: Failed to establish a new connection: [Errno 110] Operation timed out’))

And I can’t figure out why.

Thank you

Hi, I hoped you have already solved this problem. I am a beginner in gitlab CI, and recently I am stuck in running the selenium gird in gitlab CI. I also use docker:dind and docker-compose in the yml file. The remote url is suggested to be “http://theSeleniumGrid’sURL:theSeleniumGrid’sPort/wd/hub”. So i set it as “http://192.168.xxx.xxx:4444/wd/hub” or “http://selenium-hub:4444/wd/hub”, but they failed. I have read your code, so in your test code did you use the setting below?

DesiredCapabilities cap = new DesiredCapabilities();
cap.setBrowserName(“chrome”);
WebDriver driver = new RemoteWebDriver(new URL(“http://docker:4444/wd/hub”), cap);

I have tried “http://docker:4444/wd/hub”, but it still failed.I wonder how did you set the remote url in your test? Thanks.