Independence Day Offer - FLAT 30% OFF | JTINFLAT30
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 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:
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?
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.
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?
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.
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:
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.
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:\Users\John> cd.. C:\Users>cd.. 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.
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:
Selenium has much power and it can be summarized in following points:
A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.
MS SQL Server
Receive Latest Materials and Offers on Selenium Course