0% found this document useful (0 votes)
94 views

Selenium Grid With Docker Real Time

This document outlines steps to create a Selenium Grid using Docker Compose to run UI tests in parallel across different browsers on a single EC2 instance. The steps include launching an EC2 instance, installing Java, Docker, and Docker Compose, creating a docker-compose.yml file to define the grid configuration, and running the file to launch the Selenium hub and nodes containers. Tests can then be run against the hub URL in parallel on the different browser nodes.

Uploaded by

Tina Rathore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views

Selenium Grid With Docker Real Time

This document outlines steps to create a Selenium Grid using Docker Compose to run UI tests in parallel across different browsers on a single EC2 instance. The steps include launching an EC2 instance, installing Java, Docker, and Docker Compose, creating a docker-compose.yml file to define the grid configuration, and running the file to launch the Selenium hub and nodes containers. Tests can then be run against the hub URL in parallel on the different browser nodes.

Uploaded by

Tina Rathore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

+ +

Dockerizing your
UI Tests

Jatin Shharma
SDET Master Class

Docker Grid
Create Selenium Grid (Using Docker Compose) and execute the test cases in
parallel with different browsers at single instance

Step 1: Login to Aws Console and Launch an ec2 dashboard

Step 2: Launch an Amazon Linux EC2 Instance

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

Instance is running

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

Step 3: Access the server from Mobaxterm

Instance is running and up

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

Step 4: we need to install java

Command to install java:


sudo yum install java-1.8.0-openjdk

Now check whether java is installed or not with command:


Java -version

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

Step 5: we need to install docker with command:


sudo yum install docker

Check docker version with command:


docker --version

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

Step 6: after that we need to install docker-compose with commands:

sudo curl -L
"https://github.com/docker/compose/releases/download/1.26.0/docker-
compose-$(uname -s)-$(uname -m)" - o /usr/local/bin/docker-compose

sudo mv /usr/local/bin/docker-compose /usr/bin/docker-compose


sudo chmod +x /usr/bin/docker-compose

Now we need to check whether docker-compose is installed or not with command:


docker-compose -version

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

Step 7: we need to start docker service with command:


service docker start

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

#To execute this docker-compose yml file use `docker-compose -f docker-


compose-v3.yml up`

# Add the `-d` flag at the end for detached execution

# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker- compose-
v3.yml down`

version: "3"
services:
chrome:
image: selenium/node-chrome:4.4.0-20220812
shm_size: 2gb
depends_on:
selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
edge:
image: selenium/node-edge:4.4.0-20220812
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

firefox:
image: selenium/node-firefox:4.4.0-20220812
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443

selenium-hub:
image: selenium/hub:4.4.0-20220812
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

Step 8: After that we need to create file docker-compose.yml in order to run more
thanone containers in a one go.

Step 9 : Now we need to run our docker-compose file to setup the selenium hub and
nodes:
docker-compose up

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

We can check docker images with command


docker images

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

In order to check running Containers we use command


docker ps

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

Step 10: After that our selenium hub and nodes are ready and up and we can check
thatby accessing them with public ip of our amazon ec2 instance

After that we can run our selenium testcases on eclipse by providing url of our hub

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma


SDET Master Class

All test cases are running on grid parallelly on different browser nodes.

www.testautomationacademy.in SDET Master Class Notes by Jatin Shharma

You might also like