Parallel.RunEnvironments Method

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

In TestComplete, you can create cross-platform web tests that you run in your device cloud.

To run several cross-platform web tests in parallel from a TestComplete test, you can use methods of the Parallel object. Use the Parallel.RunEnvironments method to run tests in several environments in your device cloud in parallel. TestComplete will connect to the device cloud you specify, launch the needed web browsers there, and run the specified tests in each of them.

Requirements

To run tests in parallel, you must have TestExecute Lite installed on your test workstation. To learn more, see the Requirements section in Running Cross-Platform Web Tests in Parallel.

Declaration

Parallel.RunEnvironments(TestsEnvironmentsTestedURLServerURLTestTimeOutLicenseCount)

Tests [in]    Required    Array of strings    
Environments [in]    Required    Array of 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.

Example

Environments

The list of 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, CrossBrowserTesting.

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 Device Cloud Parallel licenses that you want to use 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 test environments
  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
  var serverURL = "http://hub.crossbrowsertesting.com:80/wd/hub";

  var testedURL = "https://services.smartbear.com/samples/TestComplete14/smartstore/";

  // Run tests in parallel in specified environments
  Parallel.RunEnvironments(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 test environments
  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
  serverURL = "http://hub.crossbrowsertesting.com:80/wd/hub"

  testedURL = "https://services.smartbear.com/samples/TestComplete14/smartstore/"

  # Run tests in parallel in specified environments
  Parallel.RunEnvironments(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 test environments
  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
  serverURL = "http://hub.crossbrowsertesting.com:80/wd/hub"

  testedURL = "https://services.smartbear.com/samples/TestComplete14/smartstore/"

  ' Run tests in parallel in specified environments
  Call Parallel.RunEnvironments(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 test environments
  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
  serverURL := 'http://hub.crossbrowsertesting.com:80/wd/hub';

  testedURL := 'https://services.smartbear.com/samples/TestComplete14/smartstore/';

  // Run tests in parallel in specified environments
  Parallel.RunEnvironments(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 test environments
  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
  var serverURL = "http://hub.crossbrowsertesting.com:80/wd/hub";

  var testedURL = "https://services.smartbear.com/samples/TestComplete14/smartstore/";

  // Run tests in parallel in specified environments
  Parallel["RunEnvironments"](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

Highlight search results