Disposable Selenium Grid

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.

  1. Install Docker (https://docs.docker.com/compose/install/)
  2. Put the file below somewhere
  3. Run the following command: docker-compose up

Getting the Selenium Grid Address
Use the following command to get retrieve the IP-address of your Docker container: docker-machine ip
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

Filename: docker-compose.yml

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

Share This:

One thought on “Disposable Selenium Grid

Leave a Reply

Your email address will not be published. Required fields are marked *