This post is just the continuation of last two post
In these two post, we have learned how to launch hub and node using a command line and have also seen how to use parameters efficiently. But in this post, we are going to see how to use JSON files to run your hub and nodes.
Steps:
1- We need to create json file for hub and node. Now we are going to see the json that is needed for hub.
a) Open any text editor like notepad or textedit.
b) Past content in editor from JSON for Hub code block.
c) Save this with hub.json in same place where you have your selenium-server-standalone jar file
JSON for Hub
{ "host": null, "port": 4444, "newSessionWaitTimeout": -1, "servlets" : [], "prioritizer": null, "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher", "throwOnCapabilityNotPresent": true, "nodePolling": 5000, "cleanUpCycle": 5000, "timeout": 300000, "browserTimeout": 0, "maxSession": 5, "jettyMaxThreads":-1 }you can fine it at this place. In the same fashion we can create json file for node and this would look like this, In this we are going to give value for browserName, version and platform as well in this json file and will save it as node.json JSON for node
{ "capabilities": [ { "browserName": "firefox", "maxInstances": 5, "version": "3.6", "platform": "WINDOWS" }, { "browserName": "chrome", "maxInstances": 5, "seleniumProtocol": "WebDriver" }, { "browserName": "internet explorer", "maxInstances": 1, "seleniumProtocol": "WebDriver" } ], "configuration": { "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", "maxSession": 5, "port": 5555, "register": true, "registerCycle": 5000, "hubPort": 4444, "hubHost": "ip" } }above json has been divided in two part first part takes all the parameter that we can set using desiredcapabilities for any browser and second section contains all the configuration related stuff.
java -jar selenium-server-standalone-2.48.2.jar -role hub -hubConfig hub.jsonand hit enter it will start your hub and to check this go to http://localhost:444/grid/console.

java -jar selenium-server-standalone-<version>.jar -role node -hub http://IP:4444/grid/register -nodeConfig node.jsonabove command would register node with hub and all browser instances and session detail would be present in node.json. This can be seen on http://localhost:4444/grid/console

Leave a Reply