Description
In TestComplete, you can create automated tests for mobile applications running on devices managed either by BitBar or by a private Appium server. You can run such tests in parallel by using the Parallel
object.
Use the Parallel.RunMobileTests
method to run one or several mobile tests on the specified mobile devices in parallel. The method will run each of the specified tests on each of the specified devices.
Requirements
To run mobile tests in parallel, make sure that all requirements are met:
Declaration
Parallel.RunMobileTests(Tests, Capabilities, ServerURL, TestTimeOut, InstanceCount)
Tests | [in] | Required | Array of strings | |
Capabilities | [in] | Required | Array of JSON objects or strings | |
ServerURL | [in] | Required | String | |
TestTimeOut | [in] | Optional | Integer | Default value: 0 |
InstanceCount | [in] | Optional | Integer | Default value: 0 |
Result | None |
Applies To
The method is applied to the following object:
Parameters
The method has the following parameters:
Tests
The list of tests you want to run in parallel. It can be script routines, keyword tests, and BDD scenarios. The tests must belong to the same project from which you run the method.
You can specify tests either by their full name or by tags.
The full name includes the name of the collection to which the test belongs, and the test name separated by the pipe character. For script tests, the full name also includes the name of the unit.
To run tests that match a tag, specify the tag name in the @tag_name
format.
Capabilities
An array of JSON objects or an array of string values that describe testing sessions you want to open on target mobile devices. See Connecting to Mobile Devices and Opening Testing Sessions.
ServerURL
Specifies the URL of the server that manages the target mobile devices. It can be either the BitBar hub or a private Appium server running on your local computer or on a remote computer in your local network.
TestTimeOut
The number of minutes that TestComplete waits for the test run to finish. If the test run time exceeds the specified timeout, TestComplete will stop the test run and report an error to the test log.
If the value is 0 (default value), the wait time is not limited.
InstanceCount
The maximum number of tests that you want to execute simultaneously during the test run.
Result Value
None.
Example
The sample code below shows how to use the Parallel.RunMobileTests
method to run mobile tests on several mobile devices managed by BitBar.
JavaScript, JScript
function Main_RunMobileTests_Parallel()
{
var capabilities = [
{
"automationName": "UiAutomator2",
"bitbar_app": "123",
"bitbar_device": "Google Pixel 3a Android 10",
"bitbar_findDevice": "false",
"bitbar_target": "android",
"deviceName": "Android Phone",
"newCommandTimeout": "600",
"platformName": "ANDROID"
},
{
"automationName": "UiAutomator2",
"bitbar_app": "123",
"bitbar_device": "LG Google Nexus 5 6.0.1",
"bitbar_findDevice": "false",
"bitbar_target": "android",
"deviceName": "Android Phone",
"newCommandTimeout": "600",
"platformName": "ANDROID"
}
];
var server = "https://appium.bitbar.com/wd/hub/";
var tests = ['Script|Unit1|MyTest1', 'Script|Unit1|MyTest2'];
Parallel.RunMobileTests(tests, capabilities, server);
}
function MyTest1()
{
var device = Mobile.Device();
device.FindElementByXPath("//*[@text=\"Samuel Clemens\"]").Touch();
device.FindElementById("smartbear.example.orders:id/editButton").Touch();
// …
}
function MyTest2()
{
var device = Mobile.Device();
device.FindElementByXPath("//*[@text=\"Clare Jefferson\"]").Touch();
device.FindElementById("smartbear.example.orders:id/editButton").Touch();
// …
}
Python
def Main_RunMobileTests_Parallel():
capabilities = [
{
"automationName": "UiAutomator2",
"bitbar_app": "123",
"bitbar_device": "Google Pixel 3a Android 10",
"bitbar_findDevice": "false",
"bitbar_target": "android",
"deviceName": "Android Phone",
"newCommandTimeout": "600",
"platformName": "ANDROID"
},
{
"automationName": "UiAutomator2",
"bitbar_app": "123",
"bitbar_device": "LG Google Nexus 5 6.0.1",
"bitbar_findDevice": "false",
"bitbar_target": "android",
"deviceName": "Android Phone",
"newCommandTimeout": "600",
"platformName": "ANDROID"
}
]
server = "https://appium.bitbar.com/wd/hub/"
tests = ['Script|Unit1|MyTest1', 'Script|Unit1|MyTest2']
Parallel.RunMobileTests(tests, capabilities, server)
def MyTest1():
device = Mobile.Device()
device.FindElementByXPath("//*[@text=\"Samuel Clemens\"]").Touch()
device.FindElementById("smartbear.example.orders:id/editButton").Touch()
# …
def MyTest2():
device = Mobile.Device()
device.FindElementByXPath("//*[@text=\"Clare Jefferson\"]").Touch()
device.FindElementById("smartbear.example.orders:id/editButton").Touch()
# …
}
VBScript
Sub Main
Dim capabilities : capabilities = Array(_
"{""automationName"": ""UiAutomator2"", ""bitbar_app"": ""123"", ""bitbar_device"": ""Google Pixel 3a Android 10"", ""bitbar_findDevice"": ""false"", ""bitbar_target"": ""android"", ""deviceName"": ""Android Phone"", ""newCommandTimeout"": ""600"", ""platformName"": ""ANDROID""}",_
"{""automationName"": ""UiAutomator2"", ""bitbar_app"": ""123"", ""bitbar_device"": ""LG Google Nexus 5 6.0.1"", ""bitbar_findDevice"": ""false"", ""bitbar_target"": ""android"", ""deviceName"": ""Android Phone"", ""newCommandTimeout"": ""600"", ""platformName"": ""ANDROID""}")
server = "https://appium.bitbar.com/wd/hub/"
Dim tests : tests = Array("Script|Unit1|MyTest1", "Script|Unit1|MyTest2")
Call Parallel.RunMobileTests(tests, capabilities, server)
End Sub
Sub MyTest1()
Set device = Mobile.Device()
device.FindElementByXPath("//*[@text=\"Samuel Clemens\"]").Touch
device.FindElementById("smartbear.example.orders:id/editButton").Touch
' …
End Sub
Sub MyTest2()
Set device = Mobile.Device
device.FindElementByXPath("//*[@text=\"Clare Jefferson\"]").Touch
device.FindElementById("smartbear.example.orders:id/editButton").Touch
' …
End Sub
DelphiScript
procedure MyTest1();
var device;
begin
device := Mobile.Device();
device.FindElementByXPath('//*[@text=\"Samuel Clemens\"]').Touch();
device.FindElementById('smartbear.example.orders:id/editButton').Touch();
// …
end;
procedure MyTest2();
var device;
bbegin
device := Mobile.Device();
device.FindElementByXPath('//*[@text=\"Clare Jefferson\"]').Touch();
device.FindElementById('smartbear.example.orders:id/editButton').Touch();
// …
end;
procedure Main_RunMobileTests_Parallel();
var capabilities : Array[0..1];
var server;
var tests : Array[0..1];
begin
capabilities[0] := '{"automationName": "UiAutomator2", "bitbar_app": "123", "bitbar_device": "Google Pixel 3a Android 10", "bitbar_findDevice": "false", "bitbar_target": "android", "deviceName": "Android Phone", "newCommandTimeout": "600", "platformName": "ANDROID"}';
capabilities[1] := '{"automationName": "UiAutomator2", "bitbar_app": "123", "bitbar_device": "LG Google Nexus 5 6.0.1", "bitbar_findDevice": "false", "bitbar_target": "android", "deviceName": "Android Phone", "newCommandTimeout": "600", "platformName": "ANDROID"}';
server := 'https://appium.bitbar.com/wd/hub/';
tests[0] := 'Script|Unit1|MyTest1';
tests[1] := 'Script|Unit1|MyTest2';
Parallel.RunMobileTests(tests, capabilities, server);
end;
C++Script, C#Script
function Main_RunMobileTests_Parallel()
{
var capabilities = [
'{"automationName": "UiAutomator2", "bitbar_app": "123", "bitbar_device": "Google Pixel 3a Android 10", "bitbar_findDevice": "false", "bitbar_target": "android", "deviceName": "Android Phone", "newCommandTimeout": "600", "platformName": "ANDROID"}',
'{"automationName": "UiAutomator2", "bitbar_app": "123", "bitbar_device": "LG Google Nexus 5 6.0.1", "bitbar_findDevice": "false", "bitbar_target": "android", "deviceName": "Android Phone", "newCommandTimeout": "600", "platformName": "ANDROID"}'
];
var server = "https://appium.bitbar.com/wd/hub/";
var tests = ['Script|Unit1|MyTest1', 'Script|Unit1|MyTest2'];
Parallel["RunMobileTests"](tests, capabilities, server);
}
function MyTest1()
{
var device = Mobile["Device"]();
device["FindElementByXPath"]("//*[@text=\"Samuel Clemens\"]")["Touch"]();
device["FindElementById"]("smartbear.example.orders:id/editButton")["Touch"]();
// ...
}
function MyTest2()
{
var device = Mobile["Device"]();
device["FindElementByXPath"]("//*[@text=\"Clare Jefferson\"]").Touch();
device["FindElementById"]("smartbear.example.orders:id/editButton").Touch();
// ...
}
See Also
Parallel Object
RunTests Method
Running Mobile Tests in Parallel