Documentation

Looking for something in particular?

Selenium Grid

What Is Selenium Grid?


Selenium Grid is a testing tool that allows you to run your tests on different machines against different browsers. It is a part of the Selenium Suite, which specializes in running multiple tests across different browsers, operating systems, and machines. You can connect to it with Selenium Remote by specifying the browser, browser version, and operating system you want through Selenium Remote’s Capabilities.

There are two main elements to Selenium Grid: a hub and nodes.

What is a Hub?


In Selenium Grid, the hub is a computer, the central point where we can load our tests. The hub also acts as a server, so it acts as a central point to control the network of test machines. The Selenium Grid has only one hub, and it is the master of the network.

When a test with the relevant Desired Capabilities is given to the hub, it searches for the node that matches the given configuration. For example, you could say you want to run the test on Windows 10 and Chrome browsers with any version. The hub will try to find a machine in the Grid that matches this criteria and will run the test on that machine. If there is no match, the hub returns an error. There should be only one hub in a Grid.

What Is a Node?


In Selenium Grid, a node is a test machine that opts to connect with the hub. The hub will use this test machine to run tests. A Grid network can have multiple nodes. A node is supposed to have different platforms, i.e., a different operating system and browsers. The node does not need the same platform for running as the hub.

How does Selenium Grid work?


First, you need to create a hub. Then, you can connect (or register) nodes to that hub. Nodes are where your tests will run, and the hub is responsible for ensuring your tests end up on the right node (e.g., the machine with the operating system and browser you specified in your test).

selenium grid

(Click to enlarge.)

More information


Before configuring Selenium Grid in Automation, you should have already sorted your Selenium Grid setup and have your Selenium Grid URL ready for use in Automation’s setup. Some basic information on Selenium Grid is added below, but please refer to Selenium Grid’s documentation for more information on completing this setup.

Starting a Hub


Open the command prompt and navigate to the drive where the Selenium Server is placed. Normally on Windows, this is under C:\Drive.

On the command prompt, type:

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

To verify whether the hub is running, open the browser and navigate to “http://localhost:4444”

Now click the Console link and then click View Config. The config of the hub should be displayed as below.

Setting up the node machine


To register the hub machine with the node machine, go to the command prompt and type.

java -jar selenium-server-standalone-3.141.59.jar -role node

It should show as follows.

After executing the command, return to the hub and navigate to the URL http://localhost:4444 where you can see all the web browsers.

If you want to run test cases, leave this open so you can monitor progress. Remember that you must have a host and node running to run Provar test cases on Selenium Grid. An error message will be thrown if you do not have these running.

Configuring Selenium Grid in Automation


To begin configuring Selenium Grid in Automation, add a new Browser Provider. This will help to run tests on Selenium Grid using the supported browsers (Chrome, Safari, Edge, Firefox and Internet Explorer).

Navigate to the Test Settings view and click the Browser Providers tab.

Then click the Add New (‘+’) button:

On the Add new Browser Provider screen, make sure that the Selenium Grid radio button is selected:

Add a Provider Name and a Selenium Grid URL to connect to the host, for example:

http://localhost:4444/wd/hub

Use the Test Connection button to verify the server details.

Adding browsers


Next, add the Browsers that will be used by clicking the ‘Add New’ (+) button on the Browsers section.

On the Add Selenium Grid Browsers page, first select the Platform where testing will be carried out. (You can ignore the Browser Name as this will be prepopulated based on your other selections.) The available platforms are provided as a dropdown based on the platforms assigned to the relevant Selenium Grid account.

Once you have selected the Platform, you can choose the Web Browser and Browser Version.

Note that, for Browser Version, any is also an option.

Once you are happy with the device details provided, click the OK button.

Back on the Browser Provider details screen, it should now appear as follows:

Click the OK button to finish adding the new Browser Provider.

Now that you have added a new Browser Provider for Selenium Grid, you should see this reflected on the Browser Providers tab.

Running tests on Selenium Grid


Once setup has been completed, tests can be run on Selenium Grid in Run mode, Debug mode or Run under ANT.

Run and debug mode execution


To start running test cases on Selenium Grid, first select the new Web Browser that you created above.

This can also be set for a particular test case by using the Web Browser Override on the test’s Connection step.

Then click Run or Debug to run the test.

In the host you opened above, it will show the information to initiate a session with the desired capabilities, and it will assign a node to the session.

In Node, it will display the information required node is assigned to the session with desired capability.

Provar will then run the test with the defined web browser configuration.

Progress can be monitored as usual in the Test Runner.

Run under ANT execution


Provar also provides Run under ANT execution for Selenium Grid.

To select this, right-click on the test(s) or folder and select Run Under ANT.

In the ANT Dialog, select the new Web Browser you created above:

This will add the following parameters to the Build.xml file.

Running this file will initiate the session/run similarly to the above run and Debug mode sessions.

In Host, it will show the information to initiate a session with the desired capabilities and assign a node to the session.

In Node, it will display the information required node is assigned to the session with the desired capability.

The ANT HTML report will appear as follows.

Proxy environments


Selenium Grid execution will generally work when proxies are defined under Provar Network Settings or defined under the Desired Capability of the Browser Provider as a ‘proxyURL’ (see below).

If proxy information is set up at both levels, Provar will prefer the proxy information in the Desired Capability setting in the Browser Provider.

To add a proxy at the Browser Provider level, open the Browser Provider in Edit and go to the Desired Capabilities section.

Click the Add New (‘+’) icon.

On the Add new desired Capabilities screen, enter a Name of proxyURL and the value.

Then click OK.

Once added, use the Test Connection button to ensure the connection works as expected.

If any proxy is present during execution, an entry will be made in the hub.

Limitations


The following limitations currently exist in Provar’s implementation of Selenium Grid.

Accessing Chrome profiles


Normally, when Provar’s test execution happens locally, Provar users can specify the Google Chrome profile that should be used in the execution. This is not supported when executing tests over Selenium Grid, as the execution will happen at the remote node. Due to this limitation, you’ll need to re-provide a password and verification token when executing over Selenium Grid, or your IP must be whitelisted. Salesforce should know from where the request is coming so it can provide login access to execute the tests.

Accessing locally stored files


Normally, Provar allows you to download a file locally to perform actions such as assertions. This is not supported when executing tests on Selenium Grid because the remote node cannot access the locally downloaded file, so any tests that use locally downloaded files will not run successfully.

If you are affected by these limitations, please contact Provar support directly for advice.


Feedback

Was this article helpful for you?
Documentation library

Trying to raise a case with our support team?

We use cookies to better understand how our website is used so we can tailor content for you. For more information about the different cookies we use please take a look at our Privacy Policy.

Scroll to Top