Description
In TestComplete, you can create cross-platform web tests that can run in a device cloud managed by Selenium Grid. You can use the Parallel.RunWebTests
method to run one or several web tests in the device cloud in parallel. The method will connect to a device cloud, launch the needed web browsers there, and run the specified tests in each of them.
Requirements
To run tests in parallel, make sure that all requirements are met:
Declaration
Parallel.RunWebTests(Tests, Environments, TestedURL, ServerURL, TestTimeOut, LicenseCount)
Tests | [in] | Required | Array of strings | |
Environments | [in] | Required | Array of JSON objects or strings | |
TestedURL | [in] | Required | String | |
ServerURL | [in] | Required | String | |
TestTimeOut | [in] | Optional | Integer | Default value: 0 |
LicenseCount | [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.
Environments
An array of JSON objects or an array of string values that describe the environments where your tests will run. Each environment is described by the desired capabilities. The capabilities you can use are defined by your device cloud provider.
TestedURL
The URL of the web page that a web browser will open.
We recommend that you specify the complete URL of the desired page, including the protocol name, page extension, trailing slash, and so on. For instance, https://developer.mozilla.org/en-US/. You can copy the complete URL from the browser’s address bar.
ServerURL
Specifies the URL of the device cloud that manages the remote environments where your tests will run. It can be either a private cloud or a cloud provided as a service by a third-party provider, for instance, BitBar.
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.
LicenseCount
The maximum number of tests that you want to execute simultaneously during the test run.
Result Value
None.
Example
The sample code below runs the MyTest1
and MyTest2
cross-platform web tests in Safari and Chrome web browsers that it launches in the SmartBear device cloud.
JavaScript, JScript
function Main()
{
// Set a list of tests to run in parallel
var tests = ['Script|Unit1|MyTest1', 'Script|Unit1|MyTest2'];
// Set a list of target web browsers
var environments = [
{
"platform": "Mac OSX 10.14",
"browserName": "Safari",
"version": "12",
"screenResolution": "1366x768"
},
{
"deviceName": "Pixel 4",
"platformName": "Android",
"platformVersion": "10.0",
"browserName": "Chrome",
"deviceOrientation": "portrait"
}
];
// Set the URL of the device cloud server
// For EU: var serverURL = "https://eu-desktop-hub.bitbar.com/wd/hub"
var serverURL = "https://us-west-desktop-hub.bitbar.com/wd/hub";
var testedURL = "https://services.smartbear.com/samples/TestComplete15/smartstore/";
// Run tests in parallel in specified web browsers
Parallel.RunWebTests(tests, environments, testedURL, serverURL);
}
function MyTest1()
{
var browser = Sys.Browser();
var page = browser.Page("*services.smartbear.com/samples/TestComplete*/smartstore/");
…
}
function MyTest2()
{
var browser = Sys.Browser();
var page = browser.Page("*services.smartbear.com/samples/TestComplete*/smartstore/");
…
}
Python
def Main():
# Set a list of tests to run in parallel
tests = ['Script|Unit1|MyTest1', 'Script|Unit1|MyTest2']
# Set a list of target web browsers
environments = [
{
"platform": "Mac OSX 10.14",
"browserName": "Safari",
"version": "12",
"screenResolution": "1366x768"
},
{
"deviceName": "Pixel 4",
"platformName": "Android",
"platformVersion": "10.0",
"browserName": "Chrome",
"deviceOrientation": "portrait"
}
]
# Set the URL of the device cloud server
# For EU: serverURL = "https://eu-desktop-hub.bitbar.com/wd/hub"
serverURL = "https://us-west-desktop-hub.bitbar.com/wd/hub"
testedURL = "https://services.smartbear.com/samples/TestComplete15/smartstore/"
# Run tests in parallel in specified web browsers
Parallel.RunWebTests(tests, environments, testedURL, serverURL)
def MyTest1():
browser = Sys.Browser()
page = browser.Page("*services.smartbear.com/samples/TestComplete*/smartstore/")
…
def MyTest2():
browser = Sys.Browser()
page = browser.Page("*services.smartbear.com/samples/TestComplete*/smartstore/")
…
VBScript
Sub Main
' Set a list of tests to run in parallel
Dim tests : tests = Array("Script|Unit1|MyTest1", "Script|Unit1|MyTest2")
' Set a list of target web browsers
Dim environments : environments = Array(_
"{""platform"": ""Mac OSX 10.14"", ""browserName"": ""Safari"", ""version"": ""12"", ""screenResolution"": ""1366x768""}",_
"{""deviceName"": ""Pixel 4"", ""platformName"": ""Android"", ""platformVersion"": ""10.0"", ""browserName"": ""Chrome"", ""deviceOrientation"": ""portrait""}")
' Set the URL of the device cloud server
' For EU: serverURL = "https://eu-desktop-hub.bitbar.com/wd/hub"
serverURL = "https://us-west-desktop-hub.bitbar.com/wd/hub"
testedURL = "https://services.smartbear.com/samples/TestComplete15/smartstore/"
' Run tests in parallel in specified web browsers
Call Parallel.RunWebTests(tests, environments, testedURL, serverURL)
End Sub
Sub MyTest1()
Set browser = Sys.Browser()
Set page = browser.Page("*services.smartbear.com/samples/TestComplete*/smartstore/")
…
End Sub
Sub MyTest2()
Set browser = Sys.Browser()
Set page = browser.Page("*services.smartbear.com/samples/TestComplete*/smartstore/")
…
End Sub
DelphiScript
procedure MyTest1();
var browser, page;
begin
browser := Sys.Browser();
page := browser.Page('*services.smartbear.com/samples/TestComplete*/smartstore/');
…
end;
procedure MyTest2();
var browser, page;
begin
browser := Sys.Browser();
page := browser.Page('*services.smartbear.com/samples/TestComplete*/smartstore/');
…
end;
procedure Main();
var serverURL, testedURL;
var tests : Array[0..1];
var environments : Array[0..1];
begin
// Set a list of tests to run in parallel
tests[0] : = 'Script|Unit1|MyTest1';
tests[1] : = 'Script|Unit1|MyTest2';
// Set a list of target web browsers
environments[0] := '{"platform": "Mac OSX 10.14", "browserName": "Safari", "version": "12", "screenResolution": "1366x768"}';
environments[1] := '{"deviceName": "Pixel 4", "platformName": "Android", "platformVersion": "10.0", "browserName": "Chrome", "deviceOrientation": "portrait"}';
// Set the URL of the device cloud server
// For EU: serverURL := 'https://eu-desktop-hub.bitbar.com/wd/hub';
serverURL := 'https://us-west-desktop-hub.bitbar.com/wd/hub';
testedURL := 'https://services.smartbear.com/samples/TestComplete15/smartstore/';
// Run tests in parallel in specified web browsers
Parallel.RunWebTests(tests, environments, testedURL, serverURL);
end;
C++Script, C#Script
function Main()
{
// Set a list of tests to run in parallel
var tests = ['Script|Unit1|MyTest1', 'Script|Unit1|MyTest2'];
// Set a list of target web browsers
var environments = ['{"platform": "Mac OSX 10.14", "browserName": "Safari", "version": "12", "screenResolution": "1366x768"}',
'{"deviceName": "Pixel 4", "platformName": "Android", "platformVersion": "10.0", "browserName": "Chrome", "deviceOrientation": "portrait"}'];
// Set the URL of the device cloud server
// For EU: var serverURL = "https://eu-desktop-hub.bitbar.com/wd/hub"
var serverURL = "https://us-west-desktop-hub.bitbar.com/wd/hub";
var testedURL = "https://services.smartbear.com/samples/TestComplete15/smartstore/";
// Run tests in parallel in specified web browsers
Parallel["RunWebTests"](tests, environments, testedURL, serverURL);
}
function MyTest1()
{
var browser = Sys["Browser"]();
var page = browser["Page"]("*services.smartbear.com/samples/TestComplete*/smartstore/");
…
}
function MyTest2()
{
var browser = Sys["Browser"]();
var page = browser["Page"]("*services.smartbear.com/samples/TestComplete*/smartstore/");
…
}
See Also
Parallel Object
RunTests Method
Running Cross-Platform Web Tests in Parallel