Docker Selenium Grid v.3.141.59

Running your Automated Tests in parallel is very important. How you can run these tests on up and running own designed Test environment is very simple and practical using Selenium Grid. Firefox and Chrome’s latest updates are also an important part, which should be kept into consideration that you are running your scripts on the actual browser versions. All you can achieve with some basic configurations.

1- Create a file docker-compose.yml

selhub:
image: selenium/hub:3.141.59
ports:
– 4444:4444
environment:
– TZ=Europe/Berlin
– GRID_DEBUG=false
– GRID_BROWSER_TIMEOUT=3000
– GRID_CLEAN_UP_CYCLE=2000
– browserTimeout=320

firefox:
image: selenium/node-firefox:3.141.59
links:
– selhub:hub
environment:
– TZ=Europe/Berlin
– SCREEN_WIDTH=1920
– SCREEN_HEIGHT=1080
shm_size: 2g
volumes:
– /dev/shm:/dev/shm

chrome:
image: selenium/node-chrome:3.141.59
links:
– selhub:hub
environment:
– TZ=Europe/Berlin
– SCREEN_WIDTH=1920
– SCREEN_HEIGHT=1080
volumes:
– /dev/shm:/dev/shm

2- Run the following command

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

This command will fetch the necessary Chrome and Firefox images if not present locally and will create a default Selenium Grid with one Chrome and one Firefox node.

Execute the command to check the up and running containers of selenium/hub and its Chrome and Firefox containers.

docker ps

Now, if you want to scale this Selenium Grid for multiple Chrome and Firefox nodes. You can do using following two commands:

docker-compose -f docker-compose.yml scale chrome=25
docker-compose -f docker-compose.yml scale firefox=25

I have extended the existing Grid with 25 Chrome Instances and 25 Firefox instances. You can check the grid using the following URL.

https://MachineIPAddress:4444/grid/console

Or if it’s local machine then browse the following URL:

http://localhost:4444/grid/console

Use the above stated URL’s to navigate your tests to run on selenium grid. Here is the final look of Selenium Grid:

Firefox 89.* is the current actual version at the time of writing this article and Chrome is supporting 91.*. If you want always to fetch the latest image then use the tag latest in your docker-compose. always, latest Selenium Hub image will be fetched.

selhub:
image: selenium/hub:3.141.59:latest

firefox:
image: selenium/node-firefox:3.141.59:latest

chrome:
image: selenium/node-chrome:3.141.59:latest

I hope you have enjoyed this article. If you have any confusion in understanding, drop a comment. I will try to answer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s