What is Selenium Grid
Selenium Grid allows the execution of WebDriver scripts on remote machines by routing commands sent by the client to remote browser instances.
Grid aims to:
Provide an easy way to run tests in parallel on multiple machines
Allow testing on different browser versions
Enable cross platform testing
Architecture of Selenium Grid
Hub
Hub is a central point or a local machine that receives all the test requests and distributes them to the right nodes. The machine which actually triggers the test case known as Hub.
There can be only one hub in a selenium grid.
The machine which is containing the hub triggers the test case, but you will see the browser being automated on node machines.
Node
Nodes are the Selenium instances which will execute the test cases that you loaded on the Hub. Nodes can be launched on multiple machines with different platforms and browsers.
With standalone mode in Grid, setting up both hub and nodes on the same local machine is absolutely feasible and it is working seamlessly.
Is Grid right for you?
When would you use a Selenium Grid?
To run your tests in parallel, against different browser types, browser versions, operating systems
To reduce the time needed to execute a test suite
Selenium Grid runs test suites in parallel against multiple machines (called Nodes). For large and long-running test suites, this can save minutes, hours, or perhaps days. This shortens the turnaround time for test results as your application under test (AUT) changes.
Grid can run tests (in parallel) against multiple different browsers, and it can run against multiple instances of the same browser. As an example, let’s imagine a Grid with six Nodes. The first machine has Firefox’s latest version, the second has Firefox “latest minus one”, the third gets the latest Chrome, and the remaining three machines are Mac Minis, which allows for three tests to run in parallel on the latest version of Safari.
Execution time can be expressed as a simple formula:
Number of Tests * Average Test Time / Number of Nodes = Total Execution Time
15 * 45s / 1 = 11m 15s // Without Grid
15 * 45s / 5 = 2m 15s // Grid with 5 Nodes
15 * 45s / 15 = 45s // Grid with 15 Nodes
100 * 120s / 15 = 13m 20s // Would take over 3 hours without Grid
(selenium.dev)
What is Docker
Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called "containers" that have everything the software needs to run including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy and scale applications into any environment and know your code will run.
The purpose of this is to introduce Docker, so I will not go into the architecture of Docker 😁.
Benefits of using Docker
Fast, consistent delivery of your applications: Docker streamlines the development lifecycle by allowing developers to work in standardized environments using local containers which provide your applications and services. Containers are great for continuous integration and continuous delivery (CI/CD) workflows.
Responsive deployment and scaling: Docker’s container-based platform allows for highly portable workloads. Docker containers can run on a developer’s local laptop, on physical or virtual machines in a data center, on cloud providers, or in a mixture of environments.
Running more workloads on the same hardware: Docker is lightweight and fast. It provides a viable, cost-effective alternative to hypervisor-based virtual machines, so you can use more of your server capacity to achieve your business goals.
How Docker boosts our Selenium Grid
What do we usually do to config Selenium Grid:
Download jar file and run on separate machines
Host hub and register every single node to hub
Set up required dependencies to run for each machines
Manage browser version (drivers)
This is costly and sometimes a time-consuming task for the testers. However, Docker helps us to solve cost-related and time-consuming problems by:
Dependencies are bundled inside specific Selenium Docker image
Share system resources so it's more lightweight than using virtual machines
Easily to manage all version complexity with docker registry against multiple browsers and versions
Capability to scale up
Our series of setting up Selenium Grid with Docker
In this series of Selenium Grid with Docker, I will provide you instructions on how we set up:
Stay tuned for coming posts in this series.
Comments