You can add your tested ClickOnce application to the list of Tested Applications in your test project, so that you can quickly launch the application directly from TestComplete.
Adding ClickOnce Applications From the TestComplete GUI
-
If your project does not have the Tested Applications collection, add it:
-
Open the Tested Apps collection by double-clicking the TestedApps item in the Project Explorer.
-
Right-click somewhere in the TestedApps editor and select Add Application from the context menu. This will invoke the Add Tested Application wizard.
-
On the first page of the wizard, choose ClickOnce application.
-
On the next page of the wizard, specify the application information:
-
In the Startup Link, specify the URL or file path of the application deployment manifest (.application) or the installed application's shortcut (.appref-ms). You can enter the file path manually, or click the button and browse for the needed .application or .appref-ms file.
You can use environment variables in the Startup Link value, for example, %USERPROFILE% or %APPDATA%. In addition, if the entered file path includes standard system paths for which environment variables are set, you can click the down arrow button to substitute the path components with the corresponding variables.
-
In the Process to wait field, specify the file name of the application’s executable.
-
In the Wait timeout field, specify the maximum waiting time for the application to launch.
-
-
Click Finish to close the wizard.
TestComplete will add the specified ClickOnce application to the Tested Applications list.
Now, when you record a new test, you can quickly launch your tested ClickOnce application by selecting it from the drop-down list on the Recording toolbar. TestComplete will record the application launch as the Run TestedApp keyword test operation or the TestedApps.AppName.Run
scripting method.
Adding ClickOnce Tested Applications From Tests
Instead of manual configuring of TestedApps before running tests, you can add a ClickOnce application to TestedApps from your tests. For this purpose, use the TestedApps.AddClickOnceApp
method:
This method has two parameters:
-
StartupLink - The URL or file path of the application deployment manifest (.application) or the installed application's shortcut (.appref-ms).
-
ProcessToWait - The file name of the application’s executable.
The method returns the index of the newly added item in the Testeded Applications collection. You can then use the TestedApps.Items(Index)
property to get the ClickOnceTestedApp
object corresponding to the added ClickOnce application. This object lets you specify additional parameters for the ClickOnce application as well as to run it.
The following sample script demonstrates how you can use the TestedApps.AddClickOnceApp
method.
JavaScript, JScript
function Test()
{
var index = TestedApps.AddClickOnceApp("http://www.example.com/myapp/MyApp.application", "MyApp.exe");
var app = TestedApps.Items(index);
app.WaitTimeout = 60000; // launch timeout - 1 min (60000 ms)
app.Run();
// Test the application
...
app.Close();
}
Python
def Test():
index = TestedApps.AddClickOnceApp("http://www.example.com/myapp/MyApp.application", "MyApp.exe")
app = TestedApps.Items[index]
app.WaitTimeout = 60000 # launch timeout - 1 min (60000 ms)
app.Run()
# Test the application
# ...
app.Close()
VBScript
Sub Test
Dim index, app
index = TestedApps.AddClickOnceApp("http://www.example.com/myapp/MyApp.application", "MyApp.exe")
Set app = TestedApps.Items(index)
app.WaitTimeout = 60000 ' launch timeout - 1 min (60000 ms)
app.Run
' Test the application
...
app.Close
End Sub
DelphiScript
procedure Test;
var index, app;
begin
index := TestedApps.AddClickOnceApp('http://www.example.com/myapp/MyApp.application', 'MyApp.exe');
app := TestedApps.Items(index);
app.WaitTimeout := 60000; // launch timeout - 1 min (60000 ms)
app.Run;
// Test the application
...
app.Close;
end;
C++Script, C#Script
function Test()
{
var index = TestedApps["AddClickOnceApp"]("http://www.example.com/myapp/MyApp.application", "MyApp.exe");
var app = TestedApps["Items"](index);
app["WaitTimeout"] = 60000; // launch timeout - 1 min (60000 ms)
app["Run"]();
// Test the application
...
app["Close"]();
}
See Also
Testing ClickOnce Applications
Testing ClickOnce Applications - Overview
About Tested Applications