TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Selenium Grid

Scalable Selenium Grid with Docker Compose

Overview

In this tutorial, we will learn steps involved to create a Scalable Selenium Grid with Docker Compose tool. Consider the scenario of testing with multiple containers. For example, Cross browser testing on multiple browsers.

The earlier approach outlined below, would be tedious and would involve more effort and time.

Selenium Grid Setup with Docker containers.

https://www.testingdocs.com/selenium-grid-setup-with-docker-containers/

The above approach would be fine when working with one or two containers. The approach followed would be tedious to work with multiple containers and run all the steps from the command line. In this post, we will learn an efficient approach to set Scalable Selenium Grid.

Environment

  • Docker Compose/Docker containers
  • Ubuntu Linux

What is Docker Compose?

To know more about Docker Compose Tool:

https://www.testingdocs.com/docker-compose-tool/

docker-compose.yml

Choose a suitable working directory and create the docker-compose.yml file with Selenium Grid configuration. The file is just a configuration file with hub and node images names and other configuration. We will define the hub and nodes configuration in the docker-compose.yml file.

Sample file contents

hub:
 image: selenium/hub
 ports:
 - "4444:4444"
chrome:
 image: selenium/node-chrome
 links:
 - hub
firefox:
 image: selenium/node-firefox
 links:
 - hub
opera:
 image: selenium/node-opera
 links:
 - hub

—

Docker Compose YAML File

 

Scalable Selenium Grid

Spin the Selenium Grid with a single command. Change the working directory to the path where you have created the Docker configuration file. Issue the following command to start the Grid. We can see all the progress with this command.

$ sudo docker-compose up

sudo docker compose up

Docker Compose with nohup

Spin the Selenium Grid the Docker compose with nohup command. This will make the grid immune to signals and runs the grid in the background.

$ nohup sudo docker-compose up & > nohup.out 

OR in detached mode using the -d option

$ sudo docker-compose up -d  

Docker Compose nohup Scalable Selenium Grid

To know more about nohup command:

https://www.testingdocs.com/nohup-linux-command/

Verification

To check the containers and images, we can use the following commands:

$ sudo docker images

$ sudo docker ps

Grid Console

Check the Selenium grid console for the registered nodes information.

Selenium Grid on Linux

Scale up

Scaling the grid is easy with Docker compose. For example, we want to scale the Firefox nodes to 5

Issue the following command to scale the grid.

$ sudo docker-compose up –scale firefox=5

Scaling Docker Containers

Check the Grid console

Scalable Selenium Grid Linux

Notice how the grid got scaled with just one command. We can run distributed Selenium tests, parallel tests and check the Docker logs.

Stop Grid

To stop the Selenium grid we can run a simple command.

$ sudo docker-compose down

Docker Compose Down

This command stops all the containers that are configured with the compose file.

That’s it. We can easily work with multiple containers with less effort and less time setting up the grid. We can easily scale and ramp up the nodes as per the testing needs.

—

Selenium Tutorials on this website:

https://www.testingdocs.com/selenium-webdriver-tutorial/

Official Website:

https://www.selenium.dev/

Related Posts

Selenium Server Error

Selenium Grid /

Selenium Server Error: No drivers have been configured

Selenium4_Grid_Architecture

Selenium Grid /

Selenium 4 Grid Architecture

Selenium4_Grid_Components

Selenium Grid /

Selenium Grid 4.x Distributed Mode

Selenium 4 Standalone Grid

Selenium Grid /

Different Selenium Grid Modes in Selenium 4.0

Selenium grid foreground

Selenium Grid /

Run Selenium Grid in Background on Linux

‹ Selenium Grid Setup with Docker Containers› Run Selenium Grid in Background on Linux

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com