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).
(Click to enlarge.)
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:
Use the Test Connection button to verify the server details.
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.
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.
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.
- Provar Automation
- Installing Provar Automation
- Updating Provar Automation
- Using Provar Automation
- API testing
- Behavior-driven development
- Creating and importing projects
- Creating test cases
- Custom table mapping
- Debugging tests
- Defining a namespace prefix on a connection
- Defining proxy settings
- Environment management
- Exporting test cases into a PDF
- Exporting test projects
- Override auto-retry for Test Step
- Managing test steps
- Namespace org testing
- Provar desktop
- Provar Test Builder
- Refresh and Recompile
- Reintroduction of CLI license Check
- Reload Org Cache
- Running tests
- Searching Provar with find usages
- Secrets management and encryption
- Setup and teardown test cases
- Tags and Service Level Agreements (SLAs)
- Test cycles
- Test plans
- Testing browser options
- Tooltip testing
- Using the Test Palette
- Test Palette introduction
- Control test steps
- Generate Test Case
- List compare
- Page Object Cleaner
- Read test step
- String test steps
- UI Test Steps
- Using custom APIs
- Callable tests
- Data-driven testing
- Page objects
- Block locator strategies
- Introduction to XPaths
- Creating an XPath
- Label locator strategies
- Maintaining page objects
- Mapping non-Salesforce fields
- Page object operations
- Refresh and reselect field locators in Test Builder
- Using Java method annotations for custom objects
- Applications testing
- Database testing
- Document testing
- Email testing
- Mobile testing
- OrchestraCMS Testing
- Guide in Salesforce CPQ Testing in Provar
- Guide in ServiceMax Testing
- Skuid Testing
- Vlocity API Testing
- Webservices testing
- Introduction to test scheduling
- Apache Ant
- Configuration for Sending Emails via the Automation Command Line Interface
- Continuous integration
- AutoRABIT Salesforce DevOps in Provar Test
- Azure DevOps
- Running a Provar CI Task in Azure DevOps Pipelines
- Configuring the Automation secrets password in Microsoft Azure Pipelines
- Parallel Execution in Microsoft Azure Pipelines Using Multiple build.xml Files
- Parallel Execution in Microsoft Azure Pipelines using Targets
- Parallel execution in Microsoft Azure Pipelines using Test Plans
- Bitbucket Pipelines
- Gearset DevOps CI/CD
- GitHub Actions
- Integrating GitHub Actions CI to Run Automation CI Task
- Remote Trigger in GitHub Actions
- Parameterization using Environment Variables in GitHub Actions
- Parallel Execution in GitHub Actions using Multiple build.xml Files
- Parallel Execution in GitHub Actions using Targets
- Parallel Execution in GitHub Actions using Test Plan
- Parallel Execution in GitHub Actions using Job Matrix
- GitLab Continuous Integration
- Travis CI
- Execution Environment Security Configuration
- Provar Jenkins Plugin
- Parallel Execution
- Running Provar on Linux
- Salesforce DX
- Team Foundation Server
- Version control
- Provar Automation trial guide and extensions
- Salesforce Testing
- Adding a Salesforce connection
- Assert Page Error Messages on Add/Edit Product
- Internationalization support
- List and table testing
- Salesforce Release Updates
- Salesforce Lightning Testing
- Salesforce Lightning Web Component (LWC) locator support
- Salesforce console testing
- Visualforce Testing
- Provar Manager
- Best Practices
- Configurations and permissions
- Error messages
- Licensing, installation and firewalls
- Test Builder and test cases
- Release Notes