Open source tool Selenium is basically used for testing automation. One can only test web applications by Selenium; it means that you cannot test either desktop or mobile applications through Selenium. Selenium is considered as one of the best testing automation tools to test dynamic web applications. The reasons due to which it is used by most of the testing professionals and organizations are:
- Selenium is an open source or costs free testing automation tool.
- You can run the test for any OS like Mac, Linux, or Windows.
- You can use any programming language to write test scripts e.g. Java, C#, PHP, Ruby, DotNet or Perl etc.
- It can be integrated with Docker, Jenkins, or Maven to perform the continuous testing.
Selenium has various versions that can be used by the testing professionals and these suites of tools can increase the overall performance of an application. Available Selenium tools are:
- Selenium RC: A two-component tool that is used to trick the browser.
- Selenium IDE: This is a Firefox plugin that is used to quickly record and execute the test cases.
- Selenium Grid: Selenium Grid is used to running test cases on remote machines and this is also used with Selenium RC.
- Selenium WebDriver: It is a programming interface to create and execute the test cases.
In this blog, we are going to discuss Selenium Grid in detail. As apart from Selenium Grid, other techniques are used to run the test cases in sequence or parallel, while Selenium Grid is used to run the test cases at remote machines.
Here, we will discuss why and when Selenium Grid is basically used along with a quick introduction to Grid. The architecture of Grid will also be discussed in this blog and how we can build it?
What is Selenium Grid?
In Selenium suite of tools, Grid or Selenium Grid is an important tool that is capable to coordinate WebDriver or RC tests that are either running on multiple web browsers or initiated by different operating systems or hosted on different machines. Grid uses Hub-Node architecture in which only one hub is there and rest of the nodes act as slaves.
Hub node architecture means if the user has to execute approx. 100 test cases at the same time, then it will be distributed across 5 machines and every machine will run and execute 20 test cases. Even these test cases can be run in a combination with different browsers and operating systems. Here, these machines can have the different OS on which you can perform different test cases for different web browsers.
In this way, through Grid, you can save lots of your time in test execution and even in above-mentioned case you can save 1/5th
of the total time that is spent to execute tests on a single machine. Selenium Grids are present in every version of the tool, like Selenium v1, v2 or v3 etc. Grids of Selenium v2 and v3 are not that much different but are much different than the Grid of version1.
What are the Differences between Selenium Grid 1 and Grid 2?
One of the most obvious and fundamental differences between both is that Grid 1 use RC, while Grid 2 uses WebDriver to run and execute test cases. Following differences are also seen between them:
| Grid 1
|| Grid 2
|Grid 1 supports only Selenium RC commands.
||It supports both WebDriver scripts and RC commands
|It has its own remote control
||It has its own Server jar files
|Only one browser can be automated at a time
||5 browsers can be automated at a time
|It requires Apache Ant for execution
||Apache Ant is not required for execution
So, these are two basic versions of Selenium Grid. Now let’s see why should one use Selenium Grids?
Learn Selenium Grid – Why should you use it?
Today, too many web browsers are being used by the users to access websites. These web browsers may be Opera, Safari, Firefox, or Internet Explorer etc. Even every browser has different versions available that they can run on a various and different OS that may be Windows, Mac or Ubuntu Linux based OS.
Being a tester or application developer, you will try to give the best experience to your user while accessing their website on the internet. Even you will also go the extra mile to provide them world-class experiences. You are right here, as trying and providing best user experiences is your responsibility, so the application must be tested rigorously before providing it to the customer.
But sometimes it is not feasible for the testers to test website for every browser and for every OS. As it is like a challenge for them and below we have discussed where Selenium helps the testers to test application easily even in a separate and different environment combination. Selenium helps the testers in testing applications in various environments, so by using it, the users can easily test their applications in the virtual environment.
Selenium Grid Architecture Tutorial Guide for Beginners
As discussed above that Grid uses hub and node architecture, but now we will see that what is the hub and what is a node in Grid architecture in detail:
In a Grid setup, there can be only one hub that acts as a central point. All test cases are loaded into the hub and are executed on nodes. Any of the available machines can be set up as a hub that can coordinate the test execution and other activities in other hosts. Hub has the following properties:
- Hub is a central point to load the test cases.
- A grid can only have one hub.
- Hub is launched only on a single machine with single configuration say for example Windows OS and IE browser.
- The tests are executed on hub machines and the browser can be automated on the nodes.
Nodes are basically that host machines on which tests are run that are launched by the hub. One hub can launch one or more nodes. These nodes can be on the same machine or on the remote machines. A different operating system can be booted on different nodes; moreover, different types of browsers can be used on separate nodes.
Selenium Grid Tutorial guide for Beginners - How to Configure Hubs and Nodes through Commands?
From Selenium’s website, you should first download the Selenium server JAR file on the machine that already has Java installed. Place this JAR file in an appropriate directory. Following command is used to configure the hub:
C:\> cd Selenium
C:\Selenium > java –jar selenium-server-standalone-3.4.0.jar –role hub
When above code will be executed then you will see a screen which will show that Selenium Grid hub is running. If the configuration will not take place properly, then a message will display as per which “- Nodes should register to http://192.168.0.011:4444/grid/register
Here, the IP address of hub will be 192.168.0.11 and all Nodes created by this hub must be connected to this IP address. By default, Selenium Grids are hosted on port number 4444. You can also specify the port number externally as per your requirement.
Similarly, to configure the Nodes
you must download Node JAR file on the machine and place it in your C drive. You can launch Nodes and hub on the same machine and can configure Nodes through Windows command prompt. Following command is used to configure node on any machine:
java -Dwebdriver.chrome.driver=E:\chromedriver.exe -jar selenium-server-standalone-3.4.0.jar -role node -hub http://192.168.0.11:4444/grid/register
To configure nodes, we use the similar command as of hub with a short difference that is browser driver path has to be set. –role node flag is used to set host machines.
When should you Use Selenium Grid?
Now you may think that when we should use Grid. As every application has different requirement and purpose, so if you are confused that in what case you should use Grid, then following are the cases in which Grids are recommended by the experts:
- In case, if you have to run test cases in different environments means for different operating systems, different browsers, or different machines. This testing will assure that your application will be compatible with all environments and you can use and run it at anywhere.
- If you want to save time to execute your test suites, then you can also use Selenium Grids. Like if you have to run 4 test cases at the same time, then you can finish the complete set of test cases even in the quick way. The test speed is increased by the usage of Selenium Grids. These grids can run test cases in a parallel manner as a result execution speed increases a lot.
Selenium has much power and it can be summarized in following points:
- You can run multiple tests on different browsers and multiple platforms.
- Grids use hub and node concepts to run the test cases on various machines.
- You can configure Selenium hubs just to download the Selenium Server JAR files.
- Hub configuration can be done either through the command line or by user interface.
- You can also configure nodes to run test cases on different types of browsers either on similar or different machines.
- Test cases can be executed on different OS and browsers.
- AWS & Fundamentals of Linux
- Amazon Simple Storage Service
- Elastic Compute Cloud
- Databases Overview & Amazon Route 53
5 days 02 Feb 2020
- Intro to DevOps
- GIT and Maven
- Jenkins & Ansible
- Docker and Cloud Computing
6 days 03 Feb 2020
- Data Science Introduction
- Hadoop and Spark Overview
- Python & Intro to R Programming
- Machine Learning
6 days 03 Feb 2020
- Architecture, HDFS & MapReduce
- Unix Shell & Apache Pig Installation
- HIVE Installation & User-Defined Functions
- SQOOP & Hbase Installation
7 days 04 Feb 2020
- Salesforce Configuration Introduction
- Security & Automation Process
- Sales & Service Cloud
- Apex Programming, SOQL & SOSL
-0 day 28 Jan 2020
- Introduction and Software Testing
- Software Test Life Cycle
- Automation Testing and API Testing
- Selenium framework development using Testing
6 days 03 Feb 2020
- BA & Stakeholders Overview
- BPMN, Requirement Elicitation
- BA Tools & Design Documents
- Enterprise Analysis, Agile & Scrum
7 days 04 Feb 2020
- Introduction & Database Query
- Programming, Indexes & System Functions
- SSIS Package Development Procedures
- SSRS Report Design
3 days 31 Jan 2020
Receive Latest Materials and Offers on Selenium Course