gridopadesham

An end-to-end documentation on Grid

View the Project on GitHub

Image Courtesy: Boloji.com

«Back Home

Understanding the Hub parameters

Configuration parameters that can be set at the Hub.

The Selenium Grid has many a configuration parameters that would help you to tweak its behaviour to suite your needs.

The good part of all this is that you don’t need to look for documentation else where. Its embedded as part of the selenium standalone uber jar.

To see the documentation related to the Selenium Hub, run :

java -jar selenium-server-standalone-3.141.59.jar -role hub -help

See here for the documentation of the Hub.

Lets see some of the most commonly used configuration parameters applicable for the Hub.

  1. Explicitly specifying the host for the hub
  2. Having the hub listen on a different port
  3. Specifying the Hub configuration via a JSON file
  4. Disabling default servlets
  5. Capturing the Hub logs in a file

Explicitly specifying the host for the hub.

The selenium uber jar by default always uses the first Non Loopback ip4 that it finds.

Quoting the definition of Loopback address from Webopedia

Loopback address is a special IP number (127.0.0.1) that is designated for the software loopback interface of a machine. The loopback interface has no hardware associated with it, and it is not physically connected to a network. The loopback interface allows IT professionals to test IP software without worrying about broken or corrupted drivers or hardware.

Sometimes you may want to override this and provide the hostname to be used. You can do that as below :

java -jar selenium-server-standalone-3.141.59.jar -role hub \
-host 192.168.1.2 -port 8080

Since we provided a different host value, we would need to use the same value when spinning off a node. So the command would look like this :

java -jar selenium-server-standalone-3.141.59.jar -role node \
-hub http://192.168.1.2:8080/grid/register

Having the hub listen on a different port.

The Selenium Hub by default always listens on port 4444.In order to have the hub use a different port (say for e.g., 8080) spawn the Hub as shown below:

java -jar selenium-server-standalone-3.141.59.jar -role hub -port 8080

Specifying the Hub configuration via a JSON file.

Incase we feel that the command to start the hub is getting long, we can wrap up the configuration for the Hub via a JSON file as well.

So if we were to specify the host and the port in the JSON file, it could look like below :

{
    "host": "192.168.1.2",
    "port": 8080
}

Here’s the command :

java -jar selenium-server-standalone-3.141.59.jar -role hub \
-hubConfig hubconfig.json

Incase you would like to know what else can go within this JSON configuration file, take a look here

How do I disable some of the default servlets associated with the Hub ?

The Hub by default exposes the below end-points via servlets (For the sake of e.g., lets assume that the hub is running on localhost and listening on 4444 port) :

URL url = new URL("http://localhost:444/wd/hub");
RemoteWebDriver driver = new RemoteWebDriver(url, DesiredCapabilities.firefox());

You can disable some of the servlets (the ones that are marked as optional). For e.g., if you wanted to disable the console servlet and the life cycle servlet, it can be done using the below command:

java -jar selenium-server-standalone-3.141.59.jar -role hub \
-withoutServlet org.openqa.grid.web.servlet.LifecycleServlet,\
org.openqa.grid.web.servlet.beta.ConsoleServlet

Talk2Grid is one library that internally consumes some of these URLs and exposes these information in a user friendly manner.

Capturing the Hub logs in a file.

The Selenium hub logs can be redirected to a file.

For e.g., to enable debug level logs and redirect them to the file /logs/grid.log, use:

java -jar selenium-server-standalone-3.141.59.jar -role hub \
-log /logs/grid.log -debug true

«Back Home