With version 14.03, UFT got the capability to run parallel testing on mobile, which has been enhanced now with the latest version UFT 14.50, which extends the capability to run web tests parallelly. This again is the same as you might be using for mobile tests. Using CLI Tool – ParallelRunner, UFT Tests can run parallel on web browsers and mobile devices. In this post, we will look at the two methods to do parallel execution with UFT.
In this Post
What is ParallelRunner?
ParallelRunner is a Command Line Interface (CLI) tool, which enables the capability to run tests in parallel. It means that you need to use or run this tool via command prompt.
A command-line interface or command language interpreter (CLI), also known as command-line user interface, console user interface[1] and character user interface (CUI), is a means of interacting with a computer program where the user (or client) issues commands to the program in the form of successive lines of text (command lines). A program that handles the interface is called a command language interpreter or shell (computing). — from Wikipedia |
How to Run Tests in Parallel?
As mentioned above, you need to launch the command prompt and go to the <UFT installation>/bin directory. ParallelRunner command can be executed in two ways
- Passing test and environment details as command line parameters
- Passing test and environment details within a .json file
Note that, ParallelRunner and UFT cannot run at the same. You must finish your scripting, save and close UFT before you start ParallelRunner.
Assumptions to proceed further
|
Passing test and environment details as command line parameters
This method is simple and easy to use when you have a single test or configuration. You will need to run the east test separately with individual commands
- Launch Command Prompt
- Change directory to UFT Installation bin folder if not already
- Use the command below to run your test
ParallelRunner -t <test path> -b <browser> -r<results path>
You must have understood the parameters already, Just in case you need –
Parameter | Type | Required/Optional? | Description |
-t | String | Required | Defines the path to the folder containing the UFT test you want to run.
If your path contains spaces, you must surround the path with double quotes (“”). For example -t “.\GUITest Demo” Multiple tests are not supported in the same path. |
-d | String | Optional | To Run Test on Mobile Device
Define multiple devices using semi-colons (;). Define devices using a specific device ID, or find devices by capabilities, using the following attributes in this string:
One of the following: Android, iOS, Windows Phone. If this value is not defined, UFT uses the osType defined in the test’s Record and Run settings as a default.
For example: –d “manufacturer:apple,osType:iOS,osVersion:>=11.0” |
-b | String | Optional | Define multiple browsers using semi-colons (;).
Supported values include:
Note: This value overrides any settings defined in the Record and Run Settings, and any browser parameterization configured in the test. The WebUtil.LaunchBrowser method is not affected. |
-o | String | Optional | Determines the result output shown in the console during and after the test run.
Supported values include:
For example, the run status changes from Pending to Running, and then to Pass or Fail, and so on.
Disable. No output is shown in the console at all. |
-r | String | Optional | Defines the path where you want to save your test run results. By default, run results are saved at %Temp%\TempResults.
If your string contains spaces, you must surround the string with double quotes (“”). For example: – r “%Temp%\Temp Results“ |
-rl | Optional | Include in your command to automatically open the run results when the test run starts. Use the -rr parameter to determine how often it’s refreshed. | |
-rr | Integer | Optional | Determines how often an open run results file is automatically refreshed, in seconds.
For example: -rr 5 Default, if no integer is presented: 5 seconds. |
Passing test and environment details within a .json file
In this method, you need to define a JSON file in the command line as below
ParallelRunner -c <json file path>
No worries, if you are not aware of the .json file. JSON is short for JavaScript Object Notation, which gives us a collection of data in a much readable format. I take this in the same way we use objects and properties. Refer to the example below, piece of a .json file
Var car= { “model” : “Mercedes”, “version” : “A 180 Sport”, “Transmission” : “Automatic” };
When you need to access the data you use the car.model gives output as Mercedes. Know more about JSON at w3schools.
Let’s create the .json file, In the .json file, you need to add separate lines for each test. First of all the report path should be specified where you need to save your run results. Use parameter “reportPath”
{ “reportPath” : “C\\UFT\\Results”, …. …. }
Define the path of your test using the “test” parameter. To easily identify and distinguish between the run results, you must use “reportSuffix” parameter. You can choose to provide a significant relevant suffix to be added in your result file name.
Refer to the table below for the rest of the parameters to be used while creating the JSON file
Parameter | Description |
browser | String. Defines the browser to use when running the test.
Supported values include:
Note: This value overrides any settings defined in the Record and Run Settings, and any browser parameterization configured in the test. The WebUtil.LaunchBrowser method is not affected. |
deviceID |
String. Defines a device ID for a specific device in the Mobile Center device lab.
Note: When both deviceID and device capability attributes are provided, the device capability attributes will be ignored. |
manufacturer |
String. Defines a device manufacturer. |
model |
String. Defines a device model. |
osVersion |
String. Defines a device operating system version.
One of the following:
|
osType | Defines a device operating system.
One of the following:
|
For example – for a single test to run on Chrome
{ "reportPath": "C:\\UFT\\Results", "test": "C:\\UFT\\ParallelExecution\\ParallelExecutionTest1", "reportSuffix": "Web-Chrome", "env": { "web": { "browser": "Chrome" } } }
Below is an example for a test to run on Chrome and Mobile device
{ "reportPath": "C:\\UFT\\Results", "RunTests": [ { "test": " C:\\UFT\\ParallelExecution\\ParallelExecutionTest1"", "reportSuffix": "Mobile_Web", "env": { "web": { "browser": "Chrome" }, "mobile": { "device": { "manufacturer": "motorola", "model": "Nexus 6", "osVersion": "7.0", "osType": "Android" } } }
Once your JSON file is ready you can execute it with ParallelRunner in the command prompt
To stop the execution use CTRL + C at the command prompt.
Some Limitations of ParallelRunner
- Parallel Runner Supports running up to four tests in parallel. This is good for the cases, where you need to run on multiple combinations. It will need to wait till the execution of your first four combinations are done
- All Web 2.0 toolkits (ASP dot NET AJAX, Dojo, Ext-JS, GWT, jQueryUI, SiebelOpenUI, and YahooUI) are not supported when using ParallelRunner.
- Below test objects and methods are not supported if used in your script
- .Object method
- WebFile objects
- SystemUtil.Run method (recommended WebUtil.LaunchBrowser)
- Run results can be viewed in IE versions 10 or higher
[…] Parallel test on mobile device was introduced in the previous version UFT 14.03. This has been enhanced further including the capability to execute web tests to run in parallel. Both Mobile and web parallel runs can be done via CLI tool ParallelRunner, which can be found in “bin” folder at UFT Installation folder. You will be able to trigger parallel test runs from Jenkins as well. Know more details here. […]