Introduction to Selenium Grid – What is Selenium Grid?

Let us Try to understand about selenium grid from an example.
Example 1:
Consider a scenario where you want to execute 1000 test cases. You can do this by setting “thread-count” to suppose 5. So, here using threads your test cases will be executed. One thread will execute 200 test cases. So, time taken will be 1/5th of total time.
Now, let us say, you want to execute multiple test cases (or same test cases) on multiple operating systems and on multiple browsers.  Suppose 1000 test cases need to be executed on Windows OS, Linux OS (on Mozilla Firefox, chrome, safari, IE -> all 4 browsers). In this case, we can use Selenium Grid by setting various nodes on the hub machine.
Example 2:
There are so many web browsers which are in use today. Users may be using either Chrome or Firefox or Safari or Opera or even Internet Explorer for reading this very blog. They may be using different versions of the browsers. They may also be running these browsers on any OS, be it Windows or Mac or Ubuntu or any other distribution of Linux.
What if the users were seeing something important on the internet? Something important to your business. Wouldn’t you want to go that extra mile (testing the web app) just to ensure that your users and/ or customers get the best user experience? You would, right?
Well, you should!
But the question is, how feasible is it? Will you be able to spend time testing your web app on every possible OS and every available web browser? Hmm, that sounds like a bit of a challenge. This is where Selenium Grid fits the bill and helps save your time and energy.
Observe below diagram.
The above example shows, in Selenium Grid, we have a concept of Hub and Nodes. Hub is set on a machine from which you are trying to execute the test cases. On hub, we can set multiple nodes (suppose as like multiple Operating systems / multiple computes) and on these multiple nodes, various browsers can be set for test execution. All these things are virtually.
So, in short, Selenium-grid works on different machines against different browsers at the same time. Selenium grid support distributed test execution environment.
when to use selenium grid:
1.Run your tests against different browsers, operating systems, and machines all at the same time. This will ensure that the application you are testing is fully compatible with a wide range of browser- O.S combinations.
2.Save time in the execution of your test suites. If you set up Selenium Grid to run, say, 4 tests at a time, then you would be able to finish the whole suite around 4 times faster.
Grid concept is introduced to support parallel execution of test cases.
For Example, executing the same test case in different browsers in different operating systems.
Executing a set of test cases at an instance – This could be elaborated as below: if you are running a set of 30 test cases which consumes around 5 mins each, run time for the test suite will be 5*30(You have wait until first test cases execution is completed to start second test case execution) = 150 Mins. If the same is ran through GRID it triggers 30 instance of test cases at once, so 5*1 = 5 Mins (All the test cases will run at once as 30 different browser instances will be opened).
Advantages of using selenium Grid – 
         1.       It allows running test cases in parallel with different browsers.
         2.       It reduces script execution time.
         3.       It provides the flexibility to run your test automation scripts on different browsers and different OS at the same time.

Leave Comment

Your email address will not be published. Required fields are marked *

Looking for learning Framework Development from Scratch? Lookout for Detailed Framework Development videos on YouTube here -

https://www.youtube.com/automationtalks

Get the Framework code at Github Repo: https://github.com/prakashnarkhede?tab=repositories