Day 1 out of 30 :)

How do you start with selenium grid? From scratch ? When you have no idea of what that is ? Today I'm going to give you answers to that questions! Check it out and share if you liked it !

What Selenium Grid is, and what is not ?

For sure is not a silver lining for automation. And for sure Selenium Grid for beginner is not a simple solution.

That's why I create this blog post - for others to start using it with simpler step-by-step guides :)

Selenium Grid is a type of server, that you can use for making Selenium Automation Testing without having a GUI - so for typical server-type computer.

Selenium Grid has it's potential to make a better testing environment - because you can plug-and-play using docker and then plug it to some type of CI.

In that way - you can fully combine your web-automation testing into your CI environment.

What Selenium Grid is made of ?

Selenium Grid consists of Hub and Nodes.

Hub is the Central point to which you send commands about your tests.

Nodes are just regular workers Like a regular programmer - you push your tests via Hub to them. Nodes can be a of a different type - for example a Firefox Browser Node, or a Mozilla Google Browser Node.

How to start Selenium Grid?

For start, install docker Installation Tips from DigitalOcean for Ubuntu 16.04

Then It's pretty easy to make a Selenium Hub with Nodes. Just follow this instructions Here is link to gh-source for documentation:

Create a docker-internal network

Creating for nodes and hub to easier recognize themselves via network:

docker network create grid

Warning - if you have problems with docker network command

You should check whether your docker-engine version is of 1.22 API - how ?

docker version Example :

Server API version: 1.18

Mine unfortunatelly has a 1.18 :( so I'm stuck with no-docker-network)

You can also check Docker Engine Versions.

Create a Hub (including docker network)

docker run -d -p 4444:4444 --net grid --name selenium-hub selenium/hub:3.8.1-francium

Create a Hub ( without docker network):

docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.8.1-francium

Now you can also check whether a hub has started it's job, by checking:

docker logs selenium-hub 

If you see something like :

- Selenium Grid hub is up and running as a last line from log - that it means you have successfully created a working Selenium Hub ! :)

Create Nodes (including docker network)

docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-chrome:3.8.1-francium
docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-firefox:3.8.1-francium

Create Nodes (without docker network)

docker run -d --link selenium-hub:hub --name selenium-node-chrome -v /dev/shm:/dev/shm selenium/node-chrome:3.8.1-francium
docker run -d --link selenium-hub:hub --name selenium-node-firefox -v /dev/shm:/dev/shm selenium/node-firefox:3.8.1-francium

If you can see from:

docker logs selenium-node-chrome

Something like this:

22:11:06.319 INFO - Selenium Grid node is up and ready to register to the hub
22:11:06.324 INFO - Starting auto registration thread. Will try to register every 5000 ms.
22:11:06.325 INFO - Registering the node to the hub:
22:11:06.377 INFO - The node is registered to the hub and ready to use

Than it means you have successfully registered a Selenium Node ! Which means you have successfully created a Selenium Grid Stack from which you can create your automated tests within CI :)


That's it :) Comment, share or don't :)

BTW : I have a Todoist redeem code for anyone how will give me a good idea for next article :)

BTW! This post is inspired by MiroBurn VLog S3E34 ! Totally out of the blue I've decided to accept his challenge of 30-days contributing to society(in my version it's a 30 days of posting an article for blog).

Keep Finger crossed for me :)

See you tomorrow! Cheers!


comments powered by Disqus