Skip to content

Instantly share code, notes, and snippets.

@ziouf
Last active June 5, 2018 09:31
Show Gist options
  • Save ziouf/ca5504206a14c966c566f8757dda163d to your computer and use it in GitHub Desktop.
Save ziouf/ca5504206a14c966c566f8757dda163d to your computer and use it in GitHub Desktop.
Docker-compose Selenium grid file

Docker-compose : Selenium Grid stack

Why this GIST ?

Selenium official documentation dont specify that it's mandatory to have a window manager in node container to use webDriver.manage().window().maximize();. I've found that debug node images are embeding fluxbox window manager unlike standard node images.

Run

docker-compose -f docker-compose.yml up -d

Jenkins Job Pre-Step and Post-Step

# Pre-Step
# Selenium grid initialisation
docker run --rm -d --net ci --name qa-hub -e GRID_TIMEOUT=10                      selenium/hub
docker run --rm -d --net ci --name qa-ch  -e HUB_HOST=qa-hub -v /dev/shm:/dev/shm selenium/node-chrome-debug
docker run --rm -d --net ci --name qa-ff  -e HUB_HOST=qa-hub -v /dev/shm:/dev/shm selenium/node-firefox-debug

# Post-Step
# Clean containers
docker stop $(docker container ls -f 'name=qa-' -q)

Keep in mind that ci network is the one Jenkins slave is attached to. If Jenkins slave is attached to default network replace ci by default

Credits

version: '3'
services:
hub:
image: selenium/hub
environment:
- GRID_TIMEOUT=10
ports:
- 4444:4444/tcp
node-ch:
image: selenium/node-chrome-debug
depends_on:
- hub
volumes:
- /dev/shm:/dev/shm:rw
environment:
- HUB_HOST=hub
- HUB_PORT=4444
node-ff:
image: selenium/node-firefox-debug
depends_on:
- hub
volumes:
- /dev/shm:/dev/shm:rw
environment:
- HUB_HOST=hub
- HUB_PORT=4444
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment