Over time your Selenium Grid might become unstable due to browsers not being closed properly, browser error popups and so on. This blogpost will cover the creation of a disposable Selenium Grid. Since the introduction of Docker the creation of containers (a kind of virtual machine) became a lot easier. With Docker-compose you can even describe your multi-container setup in a recipe-style providing step-by-step procedures.
- Install Docker (https://docs.docker.com/compose/install/)
- Put the file below somewhere
- Run the following command:
Getting the Selenium Grid Address
Use the following command to get retrieve the IP-address of your Docker container:
In your script you can use
http://[IP]:4444/wd/hub in order to connect to your Selenium Grid.
Scaling you Selenium Grid
With the following command you can easily scale up/down your Selenium Grid
docker-compose scale chromenode=15 firefoxnode=15
seleniumhub: image: selenium/hub:latest ports: - 4444:4444 environment: - GRID_MAX_SESSION=50 firefoxdebug: image: selenium/node-firefox-debug:latest environment: SCREEN_WIDTH: 2880 SCREEN_HEIGHT: 1800 ports: - 5900 links: - seleniumhub:hub firefoxnode: image: selenium/node-firefox:latest environment: SCREEN_WIDTH: 2880 SCREEN_HEIGHT: 1800 links: - seleniumhub:hub chromenode: image: selenium/node-chrome:latest environment: SCREEN_WIDTH: 2880 SCREEN_HEIGHT: 1800 links: - seleniumhub:hub