Integration With AQtime Using the AQtimeIntegration and AQtime Objects

Applies to TestComplete 12.60, last modified on September 17, 2018

This example demonstrates how you can automate application profiling with AQtime by using the AQtimeIntegration and AQtime objects.

The following code opens a project in AQtime, selects the Coverage profiler, starts profiling, simulates user actions against the application, gets the profiling results and exports them to files. The links to the exported results are posted to the test log.

JavaScript, JScript

function Test()
{

  // Check AQtime version
  if (! AQtimeIntegration.IsSupportedVersionAvailable("8"))
    Log.Error("The required version of AQtime is not installed.");
  else
  {
    // Specify the desired AQtime version
    AQtimeIntegration.CurrentVersion = 8;

    // Create a new project
    if (AQtime.CreateProjectFromModule("C:\\Tested Apps\\SampleApp.exe"))
    {
      // Select the desired profiler
      AQtime.SelectProfiler("Coverage Profiler");

      // Start profiling
      if (AQtime.StartProfiling())
      {
        // Simulate user actions against the application
        var p = Sys.Process("SampleApp");
        var w = p.Window("MainForm", "*");
        // …
        // Clear the test results and continue profiling
         AQtime.ClearResults();
        // …

        // Close the application
        p.Close();

        // Wait until the profiling is over and
        // export profiling results
        AQtime.WaitAndExportResults("C:\\Results\\MySummaryResults.xml", "C:\\Results\\MyResults.xml");

        // Close AQtime
        AQtime.Close();
      }
    }
  }

}

Python

def Test():

  # Check AQtime version
  if not AQtimeIntegration.IsSupportedVersionAvailable("8"):
    Log.Error("The required version of AQtime is not installed.")
  else:
    # Specify the desired AQtime version
    AQtimeIntegration.CurrentVersion = 8

    # Create a new project
    if (AQtime.CreateProjectFromModule("C:\\Tested Apps\\SampleApp.exe")):
      # Select the desired profiler
      AQtime.SelectProfiler("Coverage Profiler")

      # Start profiling
      if AQtime.StartProfiling():
        # Simulate user actions against the application
        p = Sys.Process("SampleApp")
        w = p.Window("MainForm", "*")
        # ...
        # Clear the test results and continue profiling
        AQtime.ClearResults()
        # ...

        # Close the application
        p.Close()

        # Wait until the profiling is over and
        # export profiling results
        AQtime.WaitAndExportResults("C:\\Results\\MySummaryResults.xml", "C:\\Results\\MyResults.xml")

        # Close AQtime
        AQtime.Close()

VBScript

Sub Test()

  ' Check AQtime version
  If Not AQtimeIntegration.IsSupportedVersionAvailable("8") Then
    Log.Error "The required version of AQtime is not installed."
  Else
    ' Specify the desired AQtime version
    AQtimeIntegration.CurrentVersion = 8

    ' Create a new project
    If AQtime.CreateProjectFromModule("C:\Tested Apps\SampleApp.exe") Then
      ' Selects the desired profiler
      AQtime.SelectProfiler "Coverage Profiler"

      ' Start profiling
      If AQtime.StartProfiling Then
        ' Simulate user actions against the application
        Set p = Sys.Process("SampleApp")
        Set w = p.Window("MainForm", "*")
        ' …
        ' Clear the test results and continue profiling
        AQtime.ClearResults
        ' …
        ' Close the application
        p.Close

        ' Wait until the profiling is over and
        ' export profiling results
        Call AQtime.WaitAndExportResults("C:\Results\MySummaryResults.xml", "C:\Results\MyResults.xml")

        ' Close AQtime
        AQtime.Close
      End If
    End If
  End If

End Sub

DelphiScript

procedure Test();
var p, w : OleVariant;
begin

  // Check AQtime version
  if not AQtimeIntegration.IsSupportedVersionAvailable('8') then
    Log.Error('The required version of AQtime is not installed.')
  else
  begin
    // Specify the desired AQtime version
    AQtimeIntegration.CurrentVersion := 8;

    // Create a new project
    if AQtime.CreateProjectFromModule('C:\Tested App\SampleApp.exe') then
    begin
      // Selects the desired profiler
      AQtime.SelectProfiler('Coverage Profiler');

      // Start profiling
      if AQtime.StartProfiling then
      begin
        // Simulate user actions against the application
        p := Sys.Process('SampleApp');
        w := p.Window('MainForm', '*');
        // …
        // Clear the test results and continue profiling
         AQtime.ClearResults();
        // …

        // Close the application
        p.Close;

        // Wait until the profiling is over and
        // export profiling results
        AQtime.WaitAndExportResults('C:\Results\MySummaryResults.xml', 'C:\Results\MyResults.xml');

        // Close AQtime
        AQtime.Close;
      end;
    end;
  end;

end;

C++Script, C#Script

function Test()
{

  // Check AQtime version
  if (! AQtimeIntegration["IsSupportedVersionAvailable"]("8"))
    Log["Error"]("The required version of AQtime is not installed.");
  else
  {
    // Specify the desired AQtime version
    AQtimeIntegration["CurrentVersion"] = 8;

    // Create a new project
    if (AQtime["CreateProjectFromModule"]("C:\\Tested App\\SampleApp.exe"))
    {
      // Select the desired profiler
      AQtime["SelectProfiler"]("Coverage Profiler");

      // Start profiling
      if (AQtime["StartProfiling"]())
      {
        // Simulate user actions against the application
        var p = Sys["Process"]("SampleApp");
        var w = p["Window"]("MainForm", "*");
        // …
        // Clear the test results and continue profiling
         AQtime["ClearResults"]();
        // …

        // Close the application
        p["Close"]();

        // Wait until the profiling is over and
        // export profiling results
        AQtime["WaitAndExportResults"]("C:\\Results\\MySummaryResults.xml", "C:\\Results\\MyResults.xml");

        // Close AQtime
        AQtime["Close"]();
      }
    }
  }

}

See Also

Integration With AQtime
AQtimeIntegration Object
AQtime Object

Highlight search results