How to configure Selenium Grid using JSON file?

Category: Automation Framework, Selenium Grid 38 0

We have already discussed in detail about the configuration of the Selenium Grid with the command line. That previous post is the well-described post which covered all the perspectives of the Selenium Grid. Today we are going to discuss Selenium grid configuration through JSON file. You should be aware of the JSON because it has the vast significance in Selenium WebDriver. Even WebDriver uses wire protocol to send data to the browser.

Before we start Selenium Grid configuration through JSON, I would like to suggest you some awesome tutorials related to parsing of data from JSON. Here we go!

These two articles help you in parameterization through JSON. Additionally, if you want all the basic knowledge of the Selenium Grid then click below link to read more about it.

How to configure hub through JSON file in Selenium Grid?

Selenium already has defined the sample JSON file to configure the hub. We just need to download the sample file, we may make changes, only if required otherwise rest is fine.

Click here to view the Sample JSON file on Github.

Below is the same JSON file:

In this JSON file for making hub configuration, we see the definition of port, role, capabilities, etc. I have just copied the data from the hub’s JSON file and stored in the folder with name myhub.json.

Now we need to start the hub through the command line. Type below command in cmd of the folder:

Here is the screenshot when the hub is ready.

Selenium Grid Json file configuration hub

Tip:

Keep selenium server jar file and json file in the same folder of the hub machine.

You can visit http://localhost:4444/grid/console to identify whether console loaded or not.

localhost selenium grid console through JSON file

How to configure nodes through JSON file in Selenium Grid?

Our next job is to configure and register nodes on the hub through JSON file in Selenium Grid. Again, we need to download the sample JSON file for nodes. Click here to download it.

Save the above file in the folder. Next, download all the drivers for Chrome, Firefox and Internet Explorer.

Tip:

Keep selenium server jar file and JSON file of the node and all the drivers in the same folder of the node machine.

Once everything is ready then run the below command:

Note: This command will be in the same line.

Here is the screenshot of command line when a node is registered.

Selenium grid json configuration node

You should also observe that when a node is registered then the hub screen also displays the message.

After node registration

Now verify the node registration by visiting the console page.

http://ipAdressOfNodeMachine:portOfNode/grid/console

Json grid configured

Execute test cases on through RemoteWebDriver

Here is the sample program to execute tests on the node.

When we run the tests then node and hub machine display the output in the command line.

Hub during execution
Hub during execution

 

Node during execution
Node during execution

Related Articles

Add Comment