This example illustrates how you can use the TestedApp
objects in your scripts. The TestProc
routine modifies the command-line arguments from the second application in the list of tested apps (assuming that it uses the Simple run mode), then runs this application, performs some tests and then closes it.
JavaScript, JScript
function TestProc()
{
var app, p, w;
// Obtains the 2nd app in the list of tested applications
app = TestedApps.Items(1);
// Changes the command line
TestedApps.Items(1).Params.SimpleParams.CommandLineParameters = "NotOpenApp";
// Launches the application
p = app.Run();
// Performs tests
w = p.Window("MainWindowClass", "MainWindowCaption");
...
// Closes the application
p.Close();
aqUtils.Delay(2000); // Waits until the application is closed
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
TestedApps.Items[1].Params.SimpleParams.CommandLineParameters = "NotOpenApp"
# Launches the application
p = app.Run()
# Performs tests
w = p.Window("MainWindowClass", "MainWindowCaption")
# ...
# Closes the application
p.Close()
aqUtils.Delay(2000) # Waits until the application is closed
if (p.Exists):
# If the application still exists, terminates it
app.Terminate()
VBScript
Sub TestProc
' Obtains the 2nd app in the list of tested applications
Set app = TestedApps.Items(1)
' Changes the command line
TestedApps.Items(1).Params.SimpleParams.CommandLineParameters = "NotOpenApp"
' Launches the application
Set p = app.Run
' Performs tests
Set w = p.Window("MainWindowClass", "MainWindowCaption")
...
' Closes the application
p.Close
aqUtils.Delay 2000 ' Waits until the application is closed
If p.Exists Then
' If the application still exists, terminates it
app.Terminate
End If
End Sub
DelphiScript
procedure TestProc;
var
p, w, app : OleVariant;
begin
// Obtains the 2nd app in the list of tested applications
app := TestedApps.Items[1];
// Changes the command line
TestedApps.Items[1].Params.SimpleParams.CommandLineParameters := 'NotOpenApp';
// Launches the application
p := app.Run;
// Performs tests
w := p.Window('MainWindowClass', 'MainWindowCaption');
...
// Closes the application
p.Close;
aqUtils.Delay(2000); // Waits until the application is closed
if p.Exists then
// If the application still exists, terminates it
app.Terminate;
end;
C++Script, C#Script
function TestProc()
{
var app, p, w;
// Obtains the 2nd app in the list of tested applications
app = TestedApps["Items"](1);
// Changes the command line
TestedApps["Items"](1)["Params"]["SimpleParams"]["CommandLineParameters"] = "NotOpenApp";
// Launches the application
p = app["Run"]();
// Performs tests
w = p["Window"]("MainWindowClass", "MainWindowCaption");
...
// Closes the application
p["Close"]();
aqUtils["Delay"](2000); // Waits until the application is closed
if (p["Exists"])
// If the application still exists, terminates it
app["Terminate"]();
}