I've been struggling to run some tests on selenium using a docker on macOS Monterey recently. No issues with these tests on a Windows machine though, so I thought it might be somehow related to the macOS. I'm using docker-compose.
Here are some relevant error messages from the logs:
test_email-1 | --- Failed steps:
test_email-1 |
test_email-1 | Scenario: Access to <edited> # features/login copy.feature:7
test_email-1 | When I navigate to "https://<edited>" # features/login copy.feature:9
test_email-1 | Error: org.openqa.selenium.NoSuchSessionException: Unable to execute request for an
existing session: Unable to find session with ID:
test_email-1 | Build info: version: '4.1.2', revision: '9a5a329c5a'
test_email-1 | System info: host: '9d1d3cff9e3e', ip: '172.19.0.2', os.name: 'Linux',
os.arch: 'amd64', os.version: '5.10.76-linuxkit', java.version: '11.0.13'
test_email-1 | Driver info: driver.version: unknown
test_email-1 |
test_email-1 | 1 scenarios (1 failed)
test_email-1 | 10 steps (1 failed, 9 skipped)
For some reason, the session ID is blank.
Some notable errors in the logs from the hub:
tests-hub-1 | 10:33:35.570 WARN [SeleniumSpanExporter$1.lambda$export$0] -
{"eventTime": 1644402815478448222,"eventName": "exception","attributes":
{"driver.url": "<localhost url>","exception.message": "Error while creating session with the
driver service. Stopping driver service: unknown error: DevToolsActivePort file doesn't exist\n
(Driver info: chromedriver=98.0.4758.80 (<...>),platform=Linux 5.10.76-linuxkit x86_64)
(WARNING: The server did not provide any stacktrace information)\n
Command duration or timeout: 60.24 seconds\n
Build info: version: '4.1.2', revision: '9a5a329c5a'\n
System info: host: '9d1d3cff9e3e', ip: '172.19.0.2', os.name: 'Linux', os.arch: 'amd64',
os.version: '5.10.76-linuxkit', java.version: '11.0.13'\nDriver info: driver.version: unknown",
"exception.stacktrace": "org.openqa.selenium.WebDriverException:
unknown error: DevToolsActivePort file doesn't exist\n
<...>
What has been tried so far:
- Updating and reinstalling selenium
- Updating and reinstalling chromedriver
- Restarting the docker-compose multiple times
- Reinstalled Java
- Checked if the ports aren't blocked
- Tried running docker-compose and tests with and without root
- Tried using
shm_size
instead ofvolume
- Added these flags to chromedriver: --disable-dev-shm-usage, --no-sandbox
Perhaps anyone has any ideas of how to fix this or at least what should I look into when resolving this?
Edit: adding the docker-compose config:
version: '3'
services:
test:
image: <edited>:latest
networks:
- default
tty: true
volumes:
- .:/tests
depends_on:
- hub
entrypoint: "go run tests/cmd/runner"
test_email:
image: <edited>:latest
networks:
- default
tty: true
volumes:
- .:/tests
depends_on:
- hub
entrypoint: "go run tests/cmd/runner"
hub:
image: selenium/standalone-chrome:latest
networks:
- default
ports:
- "4449:4444"
- "5900:5900"
networks:
default:
driver: bridge
P.S. I'm still a novice in dockers and selenium, so please forgive me if I missed something important. Thanks in advance!