In TestComplete, you can run web tests in device clouds. That is, you record a single test on your local computer and then run it in a needed scope of web browsers in a device cloud. This way, you can easily run your tests in as many browsers, browser versions and platforms as you need.
Sequential and parallel test runs
By default, TestComplete runs only one test at a time. The test commands that we will describe below will iterate through remote environments within one test run, that is, they will work on environments sequentially. In some cases, you may want to run the same cross-platform web test on multiple environments in parallel. This is also possible. See Running Cross-Platform Web Tests in Parallel.
Video tutorial
To run your recorded web test in several test environments
-
Record your web test on your local computer (where your TestComplete is installed). See Creating and Running Cross-Platform Web Tests.
-
Modify the test so that it could run in remote test environments successfully. For instance, in script tests, remove (or comment out) lines that use the
Browsers.Item
property. In keyword tests, remove or disable the Run Browser operation. To learn more, see Running Tests in Remote Environments. -
Add test commands that will iterate through the desired environments and run your web tests in each of them:
In keyword tests (available only if you use SmartBear device clouds)
-
In your test, select all the operations you want to simulate in the device cloud.
-
Right-click the operations and then click Make Remote Browser Loop:
-
In the resulting wizard, specify the environments in which you want to run your test:
-
TestComplete will add the Remote Browser Loop operation to the recorded test and turn the selected operations to the loop’s child operations:
Running the loop on a local computer
There can be a situation when you need to run the Remote Browser Loop on a local computer. This can happen, for example, if your test fails when you run it in remote environments, and you want to debug it on a local computer. Instead of modifying the entire test, you can configure the operation to run on your local computer. To do this, select the Run on a local computer check box of the operation:
The operation will perform a single iteration and run its child operation in one of the supported web browsers on the local computer.
There must be one of the supported web browsers running on your local computer. Otherwise, the operation will post an error to the test log and will not run. Make sure to have one of the supported web browsers running.
In script tests
-
Create objects that describe the desired test environments by their capabilities. Which capabilities are supported depends on the device cloud you use. If you use a SmartBear device cloud, you can use the Generate Run Code dialog to generate the needed objects easier. You will have to remove the redundant run instructions though.
-
Create a loop that will iterate through the specified environments.
Tip: You can store environment descriptions in a file or variable and use a data-driven loop to iterate them. See Data-Driven Testing - Basic Concepts.
-
Call your recorded web test instructions in the loop.
If your recorded test is also a script test, call it as you usually would call any script routine. If your recorded test is a keyword test, use the
KeywordTests.Test_Name.Run
method to run it.The example below shows how to describe several remote test environments by their capabilities, connect to the CrossBrowserTesting device cloud, iterate through the described environments, and run the
Test1
keyword test in each of them:JavaScript, JScript
function Main()
{
var url = "http://services.smartbear.com/samples/TestComplete15/smartstore/";
var server = "http://hub.crossbrowsertesting.com:80/wd/hub";
var remotes = [
{
browserName: 'safari',
version: '13',
platform: 'Mac OSX 10.15',
username: 'user_name',
password: 'mypassword1'
},
{
browserName: 'chrome',
deviceName: 'Nexus 9',
username: 'user_name',
password: 'mypassword1'
}];
for (var i = 0; i < remotes.length; i++)
{
Browsers.RemoteItem(server, JSON.stringify(remotes[i])).Run(url);
KeywordTests.Test1.Run();
}
}Python
def Main():
url = "http://services.smartbear.com/samples/TestComplete15/smartstore/";
server = "http://hub.crossbrowsertesting.com:80/wd/hub";
remotes = [
{
"browserName": "safari",
"version": "13",
"platform": "Mac OSX 10.15",
"username": "user_name",
"password": "mypassword1"
},
{
"browserName": "chrome",
"deviceName": "Nexus 9",
"username": "user_name",
"password": "mypassword1"
}];
for i in range (0, len(remotes)):
Browsers.RemoteItem[server, remotes[i]].Run(url)
KeywordTests.Test1.Run()VBScript
Sub Main
url = "http://services.smartbear.com/samples/TestComplete15/smartstore/"
server = "http://hub.crossbrowsertesting.com:80/wd/hub"
Dim remotes: remotes = Array(_
"{""browserName"": ""safari"", ""version"": ""13"", ""platform"": ""Mac OSX 10.15"", ""username"": ""user_name"", ""password"": ""mypassword1""}",_
"{""browserName"": ""chrome"", ""deviceName"": ""Nexus 9"", ""username"": ""user_name"", ""password"": ""mypassword1""}"_
)
For i = 0 To UBound(remotes)
Call Browsers.RemoteItem(server, remotes(i)).Run(url)
KeywordTests.Test1.Run()
Next
End SubDelphiScript
procedure Main();
var url, server, i;
var remotes : array[0..1];
begin
url := 'http://services.smartbear.com/samples/TestComplete15/smartstore/';
server := 'http://hub.crossbrowsertesting.com:80/wd/hub';
remotes[0] := '{"browserName": "safari", "version": "13", "platform": "Mac OSX 10.15", "username": "user_name", "password": "mypassword1"}';
remotes[1] := '{"browserName": "chrome", "deviceName": "Nexus 9", "username": "user_name", "password": "mypassword1"}';
for i := 0 to VarArrayHighBound(remotes, 1) do
begin
Browsers.RemoteItem[server, remotes[i]].Run(url);
KeywordTests.Test1.Run();
end;
end;C++Script, C#Script
function Main()
{
var url = "http://services.smartbear.com/samples/TestComplete15/smartstore/";
var server = "http://hub.crossbrowsertesting.com:80/wd/hub";
var remotes = [
{
browserName: 'safari',
version: '13',
platform: 'Mac OSX 10.15',
username: 'username',
password: 'mypassword1'
},
{
browserName: 'chrome',
deviceName: 'Nexus 9',
username: 'username',
password: 'mypassword1'
}];
for (var i = 0; i < remotes["length"]; i++)
{
Browsers["RemoteItem"](server, JSON["stringify"](remotes[i]))["Run"](url);
KeywordTests["Test1"]["Run"]();
}
}
-
-
Run the resulting test. It will connect to your device cloud, launch the specified web browsers, and simulate test commands in each of them, one browser after another.
See Also
About Cross-Platform Web Tests
Creating and Running Cross-Platform Web Tests