Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
203 views
by The go-to Tester (232 points)
edited by
How does Grid mechanism work in Selenium?

Please explain it clearly!

1 Answer

0 like 0 dislike
by The go-to Tester (181 points)
selected by
 
Best answer

I have already explained how the server-client mechanism works in Selenium.

What is Client - Server mechanism in Selenium?

Here are steps for the client server mechanism.

Step 1: JSON request is formed and sent to the grid hub in case of grid machine or local server in case of you are running a local browser using FirefoxBrowser, ChromeBrowser and such non remote browser class.
Step 2: The server parses your query and form JQuery.
Step 3: Server executes your query in the browser and return the response in JSON format.
Step 4: JSON response is parsed by the client and returned to you.
 
The grid can be formed by setting up hub and nodes.
 
Hub: Hub is a computer or a server which will handle nodes. The client will be pointing to the hub URL using RemoteWebDriver class.
Typical example of the hub URL. http://<yourIP>:4444/wd/hub
The hub can be initiated by using below command.
 
java -jar selenium-standalone-<version>.jar -role hub
 
Once the hub is started sucessfully, you can navigate to http://<yourIP>:4444 and you should see the page with information about the grid server and other connected nodes.

 

Node: The node is a computer or a server which will host the set of browsers and connect with the hub to receive commands from the hub.
The node can be initiated with below command.
 
java -jar selenium-standalone-<version>.jar -role node -hub http://<yourIP>:4444/grid/register
 
Once node is initiated and connected to the grid, you can navigatae to http://<yourIP>:4444 on your browser and you should see the node information and browsers information. You can even specify the browser configuration to the node using -browser argument such as browserName, browserVersion, operating system, number of browser sessions, etc.  You can connect as many nodes you want to the hub. 
 
You can anytime navigate to http://<yourIP>:4444 on your browser to see number of nodes connected, browser configuration of each hosted browser and the grid information.
 
Based on the browser configuration you provide via DesiredCapabilites to the RemoteWebDriver class, the hub will forward session to that node.
 
Hope that helps.

 


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...