How to setup Selenium Grid in Docker | Using Docker Compose yml file | Part 1

preview_player
Показать описание
In this video we are going to see that, how to setup selenium grid on docker.

We can setup the grid on docker with easy commands using docker-compose method.

To start with, first install the docker in your system based on your operating system.

###################################################
# Add the `-d` flag at the end for detached execution
version: "3"
services:
chrome:
image: selenium/node-chrome
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-hub
- HUB_PORT_4444_TCP_PORT=4444
- NODE_MAX_INSTANCES=5

ports:
- "6900:5900"

firefox:
image: selenium/node-firefox
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-hub
- HUB_PORT_4444_TCP_PORT=4444
- NODE_MAX_INSTANCES=3

ports:
- "6902:5900"

selenium-hub:
image: selenium/hub
container_name: selenium-hub
ports:
- "4444:4444"

####################################################

To setup the grid, open the command prompt and make sure that you are at the same directory where your docker-compose file is placed.
Run the below command in sequence

docker pull selenium/hub

docker pull selenium/node-chrome

docker pull selenium/node-firefox

Above commands will download the images from docker server.
Now run the below command to setup the grid.

docker-compose up -d

Now, if you go to the browser and type the url localhost:4444

Then you will see that selenium grid is running on the provided port and two nodes are attached with it, one for browser chrome and the other one for firefox.

In case you want to stop the selenium grid setup then you can do that by typing the below command.

docker-compose down

So this is how we can setup the selenium grid in docker.

***********Please comment in case of any query.***************

Also, please see other videos as well.

Рекомендации по теме
Комментарии
Автор

Really helpful :) waiting for the second part

clashofclan
Автор

Hi, Thanks for the awesome video. I have been trying to run my test cases in docker, I prepared yaml file, when i hit docker compose up, it gets stuck after health status and its not proceeding further. Can you please help me out on this?

0.0.3:5555. Health check every 120s
comautomationuidemo-edge-1 | 09:33:31.662 INFO - Node has been added

Its neither running nor stopped after this..

suraj-sundar
Автор

Hi. Thanks for the video. Could you create a video for configuring grid 4 in docker using yml file please

sivapadmakumaran
Автор

Hi, Thanks for the video. I have a question, what if I want to use port 4443 for hub? Or in other words how do I run 2 different yml files for 2 different projects?

sarvanpix