Adding ClickOnce Applications to Tested Applications

Applies to TestComplete 15.47, last modified on January 20, 2023

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

  1. If your project does not have the Tested Applications collection, add it:

    Add the Tested Apps collection to your project

    Click the image to enlarge it.

  2. Open the Tested Apps collection by double-clicking the TestedApps item in the Project Explorer.

  3. Right-click somewhere in the TestedApps editor and select Add Application from the context menu. This will invoke the Add Tested Application wizard.

  4. On the first page of the wizard, choose ClickOnce application.

  5. 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.

    • To add a CEF application that is launched by using the ClickOnce technology, select the Allow TestComplete to interact with embedded Chromium content check box.

      Note: If you run your application outside TestComplete, or if you run it from TestComplete and enable the above-mentioned option while your application is running, you will face issues with object recognition. TestComplete will notify you about this issue and show the Dfsvc.exe was launched before the tested application message. To resolve the issue, terminate the dfcvc.exe process, close the tested application, enable the option in TestComplete and launch the application again.
  6. 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:

TestedApps.AddClickOnceApp(StartupLink, ProcessToWait)

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 ClickOnceApp()
 {
  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.AccessToChromiumContent = true; // Enable support for ClickOnce CEF applications (by default it is disabled)
  
  app.Run();

  // Test the application
  ...

  app.Close();
 }

Python

def ClickOnceApp():
  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.AccessToChromiumContent = true # Enable support for ClickOnce CEF applications (by default it is disabled)

  app.Run()

  # Test the application
  # ...

  app.Close()

VBScript

Sub ClickOnceApp
  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.AccessToChromiumContent = true ' Enable support for ClickOnce CEF applications (by default it is disabled)

  app.Run

  ' Test the application
  ...

  app.Close
End Sub

DelphiScript

procedure ClickOnceApp;
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.AccessToChromiumContent := true; // Enable support for ClickOnce CEF applications (by default it is disabled)
  app.Run;

  // Test the application
  ...

  app.Close;
end;

C++Script, C#Script

function ClickOnceApp()
{
  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["AccessToChromiumContent"] = true; // Enable support for ClickOnce CEF applications (by default it is disabled)
  app["Run"]();

  // Test the application
  ...

  app["Close"]();
}

See Also

Testing ClickOnce Applications
Testing ClickOnce Applications - Overview
About Tested Applications

Highlight search results