I am using the docker-compose from the docker site to spin up a selenium grid (below) - and the sample playwright tests which come with playwright. I can run the tests locally, but when I try to use the selenium grid I get:
Error: browserType.launch: WebSocket error: connect ETIMEDOUT 10.0.1.3:4444
=========================== logs ===========================
<selenium> connecting to http://localhost:4444/
<selenium> connected to sessionId=6d694b7555264036b595224d8f91e394
<selenium> using selenium v4
<selenium> retrieved endpoint ws://10.0.1.3:4444/session/6d694b7555264036b595224d8f91e394/se/cdp for sessionId=6d694b7555264036b595224d8f91e394
<ws connecting> ws://10.0.1.3:4444/session/6d694b7555264036b595224d8f91e394/se/cdp
<ws error> ws://10.0.1.3:4444/session/6d694b7555264036b595224d8f91e394/se/cdp error connect ETIMEDOUT 10.0.1.3:4444
<ws connect error> ws://10.0.1.3:4444/session/6d694b7555264036b595224d8f91e394/se/cdp connect ETIMEDOUT 10.0.1.3:4444
<ws disconnected> ws://10.0.1.3:4444/session/6d694b7555264036b595224d8f91e394/se/cdp code=1006 reason=
<selenium> disconnecting from sessionId=6d694b7555264036b595224d8f91e394
<selenium> disconnected from sessionId=6d694b7555264036b595224d8f91e394
============================================================
I have had this working with webdriverIO - though due to hardware failure I lost my notes.
I have tried this with both windows and macOS, both have a firewall. Do I need to open ports on the firewall? (Not a network guru)
Any other suggestions? I have started the grid as per the comments and can see the grid is up when I goto localhost:4444/ui
# To start Docker in Swarm mode, you need to run `docker swarm init`
# To deploy the Grid, `docker stack deploy -c docker-compose-v3-swarm.yml grid`
# Stop with `docker stack rm grid`
# Stop swarm mode `docker swarm leave --force`
version: "3.7"
services:
chrome:
image: selenium/node-chrome:4.15.0-20231110
shm_size: 2gb
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
deploy:
replicas: 1
entrypoint: bash -c 'SE_OPTS="--host $$HOSTNAME" /opt/bin/entry_point.sh'
edge:
image: selenium/node-edge:4.15.0-20231110
shm_size: 2gb
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
deploy:
replicas: 1
entrypoint: bash -c 'SE_OPTS="--host $$HOSTNAME" /opt/bin/entry_point.sh'
firefox:
image: selenium/node-firefox:4.15.0-20231110
shm_size: 2gb
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
deploy:
replicas: 1
entrypoint: bash -c 'SE_OPTS="--host $$HOSTNAME" /opt/bin/entry_point.sh'
selenium-hub:
image: selenium/hub:4.15.0-20231110
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
the official documentation for playwright https://playwright.dev/docs/selenium-grid specifies how to run it.
Few things that your compose are missing:
Here is an example working compose file. (Just put proper version of hub/nodes) You can find more about env variables from selenium in links below.