How to configure and run Selenium Grid

Selenium Grid : Selenium Grid is a component of Selenium that distributes multiple tests across different browsers, operating systems, and machines so that we can execute scripts in parallel. The selenium-server-standalone package includes Hub, WebDriver, and Selenium RC to execute the scripts in grid.

Selenium Grid has a Hub and a Node.
Hub :The hub is the central point  where the tests would be triggered. A Selenium Grid has only one Hub and it is launched on a single machine once.
NodeNodes are the Selenium instances that are linked to the Hub which execute the tests. There can be one or more nodes in a grid which can be launched on multiple machines with different platforms and browsers.

Prerequisite Software:

1. Download Eclipse
2. Download Selenium Standalone Server jar

3. The Internet Explorer Driver Server

4. Google Chrome driver for selenium webdriver

5. Opera driver for selenium webdriver


Installing TestNG for Eclipse:

Step 1 : Launch Eclipse and select Main Menu 'Help' --> 'Install New Software' .

Step 2 : Enter the URL as 'http://beust.com/eclipse' and click 'Add' .

Step 3 :  Enter the name as 'TestNG' on dialog box 'Add Repository' dialog box. and click 'OK'

Step 4 : Click 'Select All'

Step 5 : Click 'Next' to continue.

Step 6 :  Click 'Next'.

Step 7 : "Accept the License Agreement" and click 'Finish'.

Step 8 : Security Warning pops up as the validity of the software cannot be established. Click 'Ok'

Step 9 : The Installer prompts to restart Eclipse for the changes to take effect. Click 'Yes'.

Configuring the Hub:

Step 1 :  Port# 4444 must be free. The following below commandon Window command window to start the Hub by launching the Selenium Server. Now we will use the port '4444' to start the hub. 
java -jar selenium-server-standalone-2.53.0.jar -port 4444 -role hub -nodeTimeout 1000
Example: java -jar F:\Grid\selenium-server-standalone-2.53.0.jar -port 4444 -role hub -nodeTimeout 1000
Step 2 : Open desired browser and navigate to the URL http://localhost:4444 from the Hub
Step 3 : Click on 'console' link  --> click 'view config'. The config of the hub would be displayed as follows. As of now, we haven't got any nodes, hence we will not be able to see the details.

Configuring the Nodes: 

Step 1 : Start Firefox Node using the following below command.
java -jar 'the location of selenium server standalone jar' -role node -hub http://PC_IP:4444/grid/register -browser browserName=firefox -port port_number
Example:
java -jar F:\Grid\selenium-server-standalone-2.53.0.jar -role node -hub http://192.168.111.141:4444/grid/register -browser browserName=firefox -port 5555
 Step 2 : Launch Internet Explorer Node using the following below on command.
java -Dwebdriver.ie.driver='the location of IE driver' -jar 'the location of selenium server standalone jar' -role webdriver -hub http://PC_IP:4444/grid/register -browser browserName=ie,platform=WINDOWS -port port_number
Example: 
java -Dwebdriver.ie.driver=F:\Grid\IEDriverServer.exe -jar F:\Grid\selenium-server-standalone-2.53.0.jar -role webdriver -hub http://192.168.111.141:4444/grid/register -browser browserName=ie,platform=WINDOWS -port 5556 
 Step 3 : Launch Chrome Node using the following below on command.
java -Dwebdriver.chrome.driver='the location of chrome driver' -jar 'the location of selenium server standalone jar' -role webdriver -hub  http://PC_IP:4444/grid/register -browser browserName=chrome,platform=WINDOWS -port port_number
Example: 
java -Dwebdriver.chrome.driver=F:\Grid\chromedriver.exe -jar F:\Grid\selenium-server-standalone-2.53.0.jar -role webdriver -hub  http://192.168.111.141:4444/grid/register -browser browserName=chrome,platform=WINDOWS -port 5557 
Step 4 : After running the command, come back to the Hub. Navigate to the URL - http://pc_ip:4444 then Click on 'console' link ,  the Hub would now display Firefox, IE and chrome node attached to it.

 

7 comments:

  1. thank you for the valuable info. can i get the same type of explanation for using netbeans instead of eclipse

    for hands on training in selenium Selenium Training in Chennai

    ReplyDelete
  2. Selenium is used in many IT companies due to its numerous advantages compared to other automation testing tools in the market. There is massive demand for automation testers to validate software and mobile applications across the world. Taking Selenium Course in Chennai will assist aspirants to enter automation testing industry!!!

    Live Interactive sessions - Selenium Training in Chennai

    ReplyDelete
  3. The blog gave me idea to configure and run selenium grid my sincere thanks for sharing this post and please continue to share this kind of post
    Selenium Training in Chennai

    ReplyDelete

  4. The biggest change in Selenium recently has been the inclusion of the WebDriver API. Driving a browser natively as a user would either locally or on a remote machine using the Selenium Server it marks a leap forward in terms of browser automation.

    Selenium WebDriver fits in the same role as RC did, and has incorporated the original 1.x bindings. It refers to both the language bindings and the implementations of the individual browser controlling code. This is commonly referred to as just "WebDriver" or sometimes as Selenium 2.
    Selenium Training Institute in Chennai | Selenium Training in Velachery

    ReplyDelete
  5. nice blog has been shared by you. really it was an awesome blog. so keep on sharing such kind of an interesting blogs. before i read this blog i didn't have any knowledge about this but now i got some knowledge.
    selenium training in chennai

    ReplyDelete
  6. Love your article! The content is very valuable. It shows that you spent time researching this and you have managed to turn it into an incredible piece of valuable content. TY. I also wrote an content on how CBD Mango Kush is non-addictive, natural, good for the mind and body.

    ReplyDelete