Description
A TestComplete project can include a list of tested applications and their attributes (command-line parameters, the number of instances to run and so on). These applications are listed in the TestedApps project item. The TestedApp
object holds one item from the list. It has methods and properties that can set application attributes, launch or close the application and so on.
To work with the entire list of Windows-based tested applications, use the TestedApps
object. To get a TestedApp
object as an item of this list, use the TestedApps.Items
property or use code like the following:
JavaScript, JScript
var TestedAppObj = TestedApps.TestedApp_Name;
Python
TestedAppObj = TestedApps.TestedApp_Name
VBScript
Set TestedAppObj = TestedApps.TestedApp_Name
DelphiScript
TestedAppObj := TestedApps.TestedApp_Name;
C++Script, C#Script
var TestedAppObj = TestedApps["TestedApp_Name"];
where TestedApp_Name
is the unique name of the tested application in the list.
Remarks
-
Windows Store applications are always represented by
WinStoreTestedApp
objects. For more information on available properties and methods, see: -
Android applications and iOS applications are always represented by specific scripting objects. For more information on available properties and methods, see the following topics:
-
Java Web Start applications are always represented by the
JavaWebStartTestedApp
object. For more information on available properties and methods, see: -
ClickOnce, Java, AIR and tested web applications with the Use special runtime object option enabled are represented by specific scripting objects rather than by the generic
TestedApp
object. For more information on specific application objects, see the following topics:
Members
Example
The sample code below shows how to use the TestedApps
and TestedApp
objects to add an application to the list of tested applications, modify its launch parameters, run the application, and then close it.
JavaScript, JScript
{
// Obtains the 2nd app in
// the list of tested applications
var app = TestedApps.Items(1);
// Changes the command line
app.Params.SimpleParams.CommandLineParameters = "NotOpenApp";
// Launches the application
var p = app.Run();
// Tests the application
...
// Closes the application
app.Close();
Delay(2000); // Waits until the application closes
if (p.Exists)
// If the application still exists, terminates it
app.Terminate();
}
Python
def TestProc():
# Obtains the 2nd app in
# the list of tested applications
app = TestedApps.Items[1]
# Changes the command line
app.Params.SimpleParams.CommandLineParameters = "NotOpenApp"
# Launches the application
p = app.Run()
# Tests the application
#...
# Closes the application
app.Close()
# Waits until the application closes
Delay(2000)
if p.Exists:
# If the application still exists, terminates it
app.Terminate()
VBScript
' Obtains the 2nd app in
' the list of tested applications
Set app = TestedApps.Items(1)
' Changes the command line
app.Params.SimpleParams.CommandLineParameters = "NotOpenApp"
' Launches the application
Set p = app.Run
' Tests the application
...
' Closes the application
app.Close
Delay 2000 ' Waits until the application closes
If p.Exists Then
' If the application still exists, terminates it
app.Terminate
End If
End Sub
DelphiScript
var
p, app : OleVariant;
begin
// Obtains the 2nd app in
// the list of tested applications
app := TestedApps.Items[1];
// Changes the command line
app.Params.SimpleParams.CommandLineParameters := 'NotOpenApp';
// Launches the application
p := app.Run;
// Tests the application
w := p.Window('MainWindowClass', 'MainWindowCaption');
...
// Closes the application
app.Close;
Delay(2000); // Waits until the application closes
if p.Exists then
// If the application still exists, terminates it
app.Terminate;
end;
C++Script, C#Script
{
// Obtains the 2nd app in
// the list of tested applications
var app = TestedApps["Items"](1);
// Changes the command line
app["Params"]["SimpleParams"]["CommandLineParameters"] = "NotOpenApp";
// Launches the application
var p = app["Run"]();
// Tests the application
...
// Closes the application
app["Close"]();
Delay(2000); // Waits until the application closes
if (p["Exists"])
// If the application still exists, terminates it
app["Terminate"]();
}
See Also
TestedApps Object
AndroidTestedApp Object
BrowserTestedApp Object
ClickOnceTestedApp Object
About Tested Applications
TestedAppWebParams Object
Working With Tested Applications in Tests
Passing Command-Line Arguments to Tested Applications
Testing Applications Running Under Another User Account