Parallel Object

Applies to TestComplete 15.63, last modified on April 23, 2024

Description

In TestComplete, you can create tests that will run in device clouds rather than on your local workstation. For such tests, you can orchestrate parallel runs. To do this, you can use methods of the Parallel object or manage the tests by using the project’s execution plan.

Requirements

Members

Example

The example below shows how to use the Parallel.RunTests method to control parallel test runs. The method runs MyTest1 and MyTest2 in parallel.

JavaScript, JScript

function Main()
{
  // Set a list of tests to run in parallel
  var tests = ['Script|Unit1|MyTest1', 'Script|Unit1|MyTest2'];

  // Run tests in parallel
  Parallel.RunTests(tests);
}

function MyTest1()
{
  var url = "http://services.smartbear.com/samples/TestComplete15/smartstore/";
  // Set the URL of the device cloud server
  // For EU: var server = "https://eu-desktop-hub.bitbar.com/wd/hub"
  var server = "https://us-west-desktop-hub.bitbar.com/wd/hub";

  // Set an environment for the test to run
  var capabilities = {
  "platform": "Mac OSX 10.14",
  "browserName": "Safari",
  "version": "12",
  "screenResolution": "1366x768"
};

  // Launch a browser in the environment
  Browsers.RemoteItem(server, JSON.stringify(capabilities)).Run(url);

  var browser = Sys.Browser();
  var page = browser.Page("*services.smartbear.com/samples/TestComplete*/smartstore/");
  …

}

function MyTest2()
{
  var url = "http://services.smartbear.com/samples/TestComplete15/smartstore/";
  // Set the URL of the device cloud server
  // For EU: var server = "https://eu-desktop-hub.bitbar.com/wd/hub"
  var server = "https://us-west-desktop-hub.bitbar.com/wd/hub";

  // Set an environment for the test to run
  var capabilities = {
  "deviceName": "Pixel 4",
  "platformName": "Android",
  "platformVersion": "10.0",
  "browserName": "Chrome",
  "deviceOrientation": "portrait"
};

  // Launch a browser in the environment
  Browsers.RemoteItem(server, JSON.stringify(capabilities)).Run(url);

  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']

  # Run tests in parallel
  Parallel.RunTests(tests)

def MyTest1():
  url = "http://services.smartbear.com/samples/TestComplete15/smartstore/"
  # Set the URL of the device cloud server
  # For EU: server = "https://eu-desktop-hub.bitbar.com/wd/hub"
  server = "https://us-west-desktop-hub.bitbar.com/wd/hub"

  # Set an environment for the test to run
  capabilities = {
  "platform": "Mac OSX 10.14",
  "browserName": "Safari",
  "version": "12",
  "screenResolution": "1366x768"}

  # Launch a browser in the environment
  Browsers.RemoteItem[server, capabilities].Run(url)

  browser = Sys.Browser()
  page = browser.Page("*services.smartbear.com/samples/TestComplete*/smartstore/")
  …

def MyTest2():
  url = "http://services.smartbear.com/samples/TestComplete15/smartstore/"
  # Set the URL of the device cloud server
  # For EU: server = "https://eu-desktop-hub.bitbar.com/wd/hub"
  server = "https://us-west-desktop-hub.bitbar.com/wd/hub"

  # Set an environment for the test to run
  capabilities = {
  "deviceName": "Pixel 4",
  "platformName": "Android",
  "platformVersion": "10.0",
  "browserName": "Chrome",
  "deviceOrientation": "portrait"
}

  # Launch a browser in the environment
  Browsers.RemoteItem(server, capabilities).Run(url)

  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")

  ' Run tests in parallel
  Parallel.RunTests(tests)
End Sub

Sub MyTest1()
  url = "http://services.smartbear.com/samples/TestComplete15/smartstore/"
  ' Set the URL of the device cloud server
  ' For EU: server = "https://eu-desktop-hub.bitbar.com/wd/hub"
  server = "https://us-west-desktop-hub.bitbar.com/wd/hub"

  ' Set an environment for the test to run
   capabilities = "{""platform"":""Mac OSX 10.14"",""browserName"":""Safari"",""version"":""12"",""screenResolution"":""1366x768""}"

  ' Launch a browser in the environment
  Browsers.RemoteItem(server, capabilities).Run(url)

  Set browser = Sys.Browser()
  Set page = browser.Page("*services.smartbear.com/samples/TestComplete*/smartstore/")
  …

End Sub

Sub MyTest2()
  url = "http://services.smartbear.com/samples/TestComplete15/smartstore/"
  ' Set the URL of the device cloud server
  ' For EU: server = "https://eu-desktop-hub.bitbar.com/wd/hub"
  server = "https://us-west-desktop-hub.bitbar.com/wd/hub"

  ' Set an environment for the test to run
  capabilities = "{""deviceName"":""Pixel 4"",""platformName"":""Android"",""platformVersion"":""10.0"",""browserName"":""Chrome"",""deviceOrientation"":""portrait""}"

  ' Launch a browser in the environment
  Call Browsers.RemoteItem(server, capabilities).Run(url)

  Set browser = Sys.Browser()
  Set page = browser.Page("*services.smartbear.com/samples/TestComplete*/smartstore/")
  …

End Sub

DelphiScript

procedure Main();
var tests : Array[0..1];
begin
  // Set a list of tests to run in parallel
  tests[0] := 'Script|Unit1|MyTest1';
  tests[1] := 'Script|Unit1|MyTest2';

  // Run tests in parallel
  Parallel.RunTests(tests);
end;

procedure MyTest1();
var url, server, capabilities, browser, page;
begin
  url := 'http://services.smartbear.com/samples/TestComplete15/smartstore/';
  // Set the URL of the device cloud server
  // For EU: server := 'https://eu-desktop-hub.bitbar.com/wd/hub'
  server := 'https://us-west-desktop-hub.bitbar.com/wd/hub';

  // Set an environment for the test to run
  capabilities := '{"platform":"Mac OSX 10.14","browserName":"Safari","version":"12","screenResolution":"1366x768"}';

  // Launch a browser in the environment
  Browsers.RemoteItem(server, capabilities).Run(url);

  browser := Sys.Browser();
  page := browser.Page('*services.smartbear.com/samples/TestComplete*/smartstore/');
  …

end;

procedure MyTest2();
var url, server, capabilities, browser, page;
begin
  url := 'http://services.smartbear.com/samples/TestComplete15/smartstore/';
  // Set the URL of the device cloud server
  // For EU: server := 'https://eu-desktop-hub.bitbar.com/wd/hub'
  server := 'https://us-west-desktop-hub.bitbar.com/wd/hub';

  // Set an environment for the test to run
  capabilities := '{"deviceName":"Pixel 4","platformName":"Android","platformVersion":"10.0","browserName":"Chrome","deviceOrientation":"portrait"}';

  // Launch a browser in the environment
  Browsers.RemoteItem(server, capabilities).Run(url);

  browser := Sys.Browser();
  page := browser.Page('*services.smartbear.com/samples/TestComplete*/smartstore/');
  …

end;

C++Script, C#Script

function Main()
{
  // Set a list of tests to run in parallel
  var tests = ['Script|Unit1|MyTest1', 'Script|Unit1|MyTest2'];

  // Run tests in parallel
  Parallel["RunTests"](tests);
}

function MyTest1()
{
  var url = "http://services.smartbear.com/samples/TestComplete15/smartstore/";
  // Set the URL of the device cloud server
  // For EU: server = "https://eu-desktop-hub.bitbar.com/wd/hub"
  server = "https://us-west-desktop-hub.bitbar.com/wd/hub";

  // Set an environment for the test to run
  var capabilities = {
  "platform": "Mac OSX 10.14",
  "browserName": "Safari",
  "version": "12",
  "screenResolution": "1366x768"
};

  // Launch a browser in the environment
  Browsers.RemoteItem(server, JSON["stringify"](capabilities))["Run"](url);

  var browser = Sys["Browser"]();
  var page = browser["Page"]("*services.smartbear.com/samples/TestComplete*/smartstore/");
  …

}

function MyTest2()
{
  var url = "http://services.smartbear.com/samples/TestComplete15/smartstore/";
  // Set the URL of the device cloud server
  // For EU: server = "https://eu-desktop-hub.bitbar.com/wd/hub"
  server = "https://us-west-desktop-hub.bitbar.com/wd/hub";

  // Set an environment for the test to run
  var capabilities = {
  "deviceName": "Pixel 4",
  "platformName": "Android",
  "platformVersion": "10.0",
  "browserName": "Chrome",
  "deviceOrientation": "portrait"
};

  // Launch a browser in the environment
  Browsers["RemoteItem"](server, JSON["stringify"](capabilities))["Run"](url);

  var browser = Sys["Browser"]();
  var page = browser["Page"]("*services.smartbear.com/samples/TestComplete*/smartstore/");
  …

}

See Also

Running Cross-Platform Web Tests in Parallel
Running Mobile Tests in Parallel

Highlight search results