Selenium Grid – Test execution in Cluster (Part-2)

In this post, we will discuss about the configuration of Hub & Node(s) with Options.

Configure Hub

To configure the Hub, please follow the below steps.

  • Download the Selenium Standalone Server from here.
  • Start the command prompt and navigate to the location, where the Selenium Standalone Server jar file was saved.
  • From command prompt, run the jar file according to below syntax.

          java –jar <selenium standalone server jar>.jar –role hub

Access Selenium Grid Console

  • The URL for Selenium-Grid console will be http://<IP>:<port>/grid/console
  • By default the Selenium-Grid will run on port 4444 (We can change this port by passing  -port parameter).
  • The URL for registering nodes is http://<IP>:<port>/grid/register
  • The URL for connecting hub is http://<IP>:<port>/wd/hub

Configure Hub with Options

We can configure Hub with different options as mentioned below.

  • -host  <String> : IP or hostname of the system

Example: java –jar <selenium standalone server jar>.jar –role hub -host “http://10.11.252.123”

  • -port <Integer> : the port number the server will use. Default value is 4444.

Example: java –jar <selenium standalone server jar>.jar –role hub -host “http://10.11.252.123” -port 8082

  • -browserTimeout <Integer> in seconds: number of seconds a browser session is allowed to hang while a WebDriver command is running (example: driver.get(url)). Minimum value is 60. An unspecified, zero, or negative value means wait indefinitely.

Example: java –jar <selenium standalone server jar>.jar –role hub -port 8082 -browserTimeOut 180

  • maxSession <String> : max number of tests that can run at the same time on the node, irrespective of the browser used
  • -timeout, –sessionTimeout <Integer> in seconds: Specifies the timeout before the server automatically kills a session that hasn’t had any activity in the last X seconds.
  • -cleanUpCycle <Integer> in milli seconds: specifies how often the hub will poll running proxies for timed-out (i.e. hung) threads.
  • throwOnCapabilityNotPresent <Boolean> in true or false: If true, the hub will reject all test requests if no compatible proxy is currently registered. If set to false, the request will queue until a node supporting the capability is registered with the grid.

Configure Node(s)

  • In Node machine(s), download the Selenium Standalone Server from here.
  • In Node machine(s), start the command prompt and navigate to the location, where the Selenium standalone server jar file was saved.
  • From command prompt, run the jar file according to below syntax.

         java –jar <selenium server jar>.jar –role node –hub http://<IP>:<port>/grid/register

  • Now, navigate to Selenium Grid console and verify the node(s) information.
  • If the node is created successfully, then the node information will be displayed in Grid console (As shown below).

Configure Node(s) with Options

  • -port <Integer> : the port number the server will use. Default value is 5555.
  • -browserTimeout <Integer> in seconds: number of seconds a browser session is allowed to hang while a WebDriver command is running (example: driver.get(url)). Minimum value is 60. An unspecified, zero, or negative value means wait indefinitely.
  • maxSession <String> : max number of tests that can run at the same time on the node, irrespective of the browser used.
  • -timeout, –sessionTimeout <Integer> in seconds: Specifies the timeout before the server automatically kills a session that hasn’t had any activity in the last X seconds.
  • -cleanUpCycle <Integer> in ms: specifies how often the hub will poll running proxies for timed-out (i.e. hung) threads.
  • -nodePolling <Integer> in ms: specifies how often the hub will poll to see if the node is still responding.
  • -nodeStatusCheckTimeout <Integer> in ms: connection/socket timeout, used for node “nodePolling“ check.
  • -registerCycle  <String>  in ms : specifies how often the node will try to register itself again. Allows administrator to restart the hub without restarting or risk orphaning) registered nodes.
  • downPollingLimit <String> : node is marked as “down” if the node hasn’t responded after the number of checks specified in [downPollingLimit].
  • -capabilities, –browser < String > : comma separated Capability values.

Example:  -capabilities browserName=firefox,maxInstances=20,platform=LINUX

-browser browserName=chrome,maxInstances=5,platform=WINDOWS

  • -log <String> filename: The filename to use for logging.

Configure Hub & Node(s) with JSON file

  • -hubConfig <String> filename: a JSON file (following grid2 format), which defines the hub properties

Examplejava –jar <selenium standalone server jar>.jar –role hub -hubConfig “<Hub JSON config file path>”

{"_comment" : "Configuration for Hub - hubConfig.json",
  "host": http://myseleniumgrid-hub.com,
  "maxSessions": 5,
  "port": 4444,
  "cleanupCycle": 5000,
  "timeout": 300000,
  "newSessionWaitTimeout": -1,
  "servlets": [],
  "prioritizer": null,
  "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
  "throwOnCapabilityNotPresent": true,
  "nodePolling": 180000,
  "platform": "WINDOWS"}
  • nodeConfig <String> filename: JSON configuration file for the node. Overrides the default values

Example:  java –jar <selenium server jar>.jar –role node –hub http://<IP>:<port>/grid/register -nodeConfig “<Node JSON config file path>”

{
  "capabilities": [
    {
      "browserName": "firefox",
      "acceptSslCerts": true,
      "javascriptEnabled": true,
      "takesScreenshot": false,
      "firefox_profile": "",
      "browser-version": "27",
      "platform": "WINDOWS",
      "maxInstances": 5,
      "firefox_binary": "",
      "cleanSession": true 
    },
    {
      "browserName": "chrome",
      "maxInstances": 5,
      "platform": "WINDOWS",
      "webdriver.chrome.driver": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
    }
 ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "maxSession": 5,
  "port": 8083,
  "register": true,
  "registerCycle": 5000,
  "hub": "http://192.168.1.6:8082",
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}
}

 


About the course

NPN Training is counted among the top ten selenium training centers in Bangalore for providing the best Selenium training in Bangalore. Our selenium course content and syllabus is designed according to the student’s requirement to accomplish everyone’s career goal.

Related Post
Selenium Grid – Test execution in Cluster (P... Selenium Grid Selenium-Grid allows you to run your tests on different machines against different browsers in parallel. Key Features of Selenium ...

Pradeep

M.r Pradeep is QA expert working as a Research Analyst at NPN Training. He is having 12 years of experience in Quality Assurance with extensive of 4 years in Automation experience (Selenium, UFT, Rest Assured, Jmeter & Soap UI). He has helped the peers/students to understand and learn Automation with Selenium and API automation with Rest Assured with Hands-On approach.