What is Selenium Grid?
Selenium Grid is a part of the Selenium Suite that is specialized to run multiple tests across different browsers, operating systems, and machines simultaneously.
Following are some of the salient features of Selenium Grid:
Execute test script on multiple machines at the same time.
Execute tests on different machines with different browsers
Execute tests on the same browser but with different versions
Save test execution time and effort
Has a Hub-node architecture, where Hub works as a central point that controls the nodes, and the nodes are the actual machines on which tests are executed.
How to work with Selenium Grid using Qualitia offline package?
In Selenium Grid, the hub is a computer, which is the central point where the tests from the Qualitia offline package are loaded. The Hub acts as the central server that controls the network of Test machines, also referred as Nodes. One Selenium Grid has only one Hub, which is the master of the network that controls all the nodes.
When a test with selected Desired Capabilities options is passed to the Hub, the Hub searches for the node that matches with options. For example, if you have defined the Desired Capabilities options to run a test on Windows 10 operating system using Chrome version XXX, the Hub will try to find a machine in the Grid that matches the criteria and runs the test on it. The Hub shows an error if no machine matches the criteria. A node, which is referred to as a Test Machine, opts to connect with the Hub. The Hub runs the tests on the test machines. A Grid network can have multiple nodes. Each node can have different platforms, that is operating systems and browsers. It is not necessary for the node to have the same platform as that of the Hub.
To set up a Grid network, first you must create a Hub and then connect (register) nodes to the Hub.
Building a Selenium Grid for Qualitia Mobile Testing
Mobile Test Automation has gained significant importance in recent times. Almost all the web applications are highly active these days and it is important to test how the applications work across devices. This is true for mobile native applications as well. At the same time, a huge number of devices and custom operating system versions have been introduced. This has made running tests manually over multiple devices difficult, even if the tests are automated.
This section guides on how you can use Appium along with Selenium Grid for Qualitia test case execution on multiple mobile devices. The following configuration was used:
Configuring the Hub
Perform the following steps to configure the hub:
Download the Selenium Standalone Server from http://docs.seleniumhq.org/download/ Start the command prompt and navigate to the folder where you placed the Selenium server jar file.
Execute the following command: java –jar selenium-server-standalone-X.XX.jar –role hub, where selenium-server-standalone-3.6.0.jar is the name of the downloaded .jar file
This starts the selenium grid server in your local ip with the default port of 4444. After you see this message, the Selenium Grid hub is up and running.
Open your browser and hit the following URL: http://<your ip>:4444/grid/console. You can now navigate to Grid Console:
Configuring the Appium Nodes
In this example, we have used two devices, Samsung S7 and Samsung S5 mini. For each of these devices, we will configure a separate grid node. To set up the grid nodes, create a separate JSON configuration file for both the devices as shown below, and upload them to the Appium server instances.
Node1.json (Android 1) { Node2.json (Android 2) { |
To run the test cases on the same machine with two devices and on two different Appium instances. the Appium Server port must be different for lauchned two Appium instances.
Executing a Test Case on a Specific Node
The node can be equipped with different capabilities and values. Let us consider a scenario where X machine is connected to x1 mobile device, Y machine is connected to y1 mobile device, and Z machine is connected to z1 mobile device.
To execute a test case :
(The following is an example to execute a test case on x1 device)
Find out the UDID of the x1 device.
While registering X machine as a node to the hub, add the following capability:
--udid UDID_of_x1_device
As a result, the node command becomesappium -p 4724 --udid 5e6453d7d240 --nodeconfig=C:\Users\Desktop\capabilities.json
Click Settings> System Execution Profile> Mobile, and enter the UDID of x1 device in the mapped Execution Profile.
Configuring the Mapped Execution Profile
Either you can create an execution profile to execute on the remote environment or edit an existing execution profile. For more information, refer to Working with Execution Profiles.
To configure the settings for executing through Selenium Grid:
Do one of the following:
To execute the test suite from a Qualitia client, open the associated execution profile.
To execute the offline suite, do the following in the order listed:
Open the offline package folder.
From the Configuration Manager folder, and double-click the Qualitia Offline Configuration Manager.
Do one of the following;
Click Browse next to Select the Suite Directory, and then locate and select the offline suite.
Enter the location path of the offline suite folder, and press Tab.
Under the Select the profile to edit, select the execution profile created to execute on remote environment.
Select the associated execution profile that is defined to execute on remote environment.
From the Mapped Execution Profile list, select the execution profile you have opened.
Set the ExecutionEnvironment as Remote.
Set the RemoteURL value to a valid remote URL that is IP and port of the remote machine.
For example: RemoteURL=http://192.168.25.123:4445
Set the GridPlatform value to a valid platform where you want to execute test cases. For example: Set the GridPlatform=Win10.
Click Save.
|
Suite Execution
Execute the test suite or offline suite you have configured. To know how to execute an offline package, refer to Offline Package.