Automating Test Cases using TestComplete Framework with Python

Modified on Mon, 29 Apr 2024 at 10:25 AM

Overview 

This topic introduces you to the TestComplete automation framework, guiding you through the process of creating, managing, executing, and maintaining test case scenarios leveraging algoQA automation process.


Prerequisites

To install TestComplete, see TestComplete Installation guide.


About TestComplete Framework

Currently applicable for: Desktop Application

TestComplete is an automated testing environment suitable for various application types and technologies, including Windows, Linux and Mac. It supports TestComplete and comes with built-in capability to utilize the Python language.


Use case

This use case demonstrates the automation of a Calculator application by integrating algoQA with the TestComplete framework using the Python language. The example showcases an in-sprint automation process, automating the steps of adding two numbers and verifying the sum.

Profiling 

Profiling is creating an offline model of an application under test (AUT), which involves mimicking a UI model of an AUT using nodes, features and UI elements. For more information, see Profiling.


Using the TestComplete Object Spy Feature

To identify objects within your application for use in your test steps, you can use TestComplete Object Spy feature. In this example, calculator application is used to illustrate the process.

Follow these steps to prepare your application for automation testing and utilize the Object Spy:

  1. Launch the TestComplete tool from your desktop and click the Object Spy toolbar button as follows:
  2. Object Spy window appears as shown:
  3. Determine the application you wish to inspect, and the application tab will display the current screen you intend to inspect. Similarly, you can identify all the necessary objects required.
  4. Mouseover the required object to inspect the element and selected element will be highlighted. All the properties will be displayed in the properties tab.  Choose the required attribute to locate the element.
  5. Navigate to Control List Panel window to update the locator. You can update the locator fetched from Object Spy tool and save it. Similarly, update the all the locators required for the objects.

Record the scenarios using Follow Me feature

Follow Me feature is used to record and save the workflow or scenario or use case. Scenario will be saved in the same sequence it has been recorded.


Note: Recording for the Follow Me feature is done in an offline model. It doesn't interact with the live application.


For more information, see Follow Me section in profiling article.


Generate Test cases

After recording the scenarios using Follow Me feature, next step is generating test cases.

Test cases are generated in Gherkin language and are Behavior-driven development (BDD) complaint. 

For more information, see Generate Test cases section in profiling article.

Editing Scenarios

Navigate to the Main Canvas, select Edit Scenarios from More Menu. All the scenarios corresponding to the project are listed in the following screen. Click Edit.

 

 


In the secondary screen, you can: 

  • Insert test steps between existing ones for more flexible scenario creation.
  • Add and list controls within the test steps.
  • Easily track the sequence of scenarios.
  • Use draggable functionality to arrange test steps.

Editing Object Repository File

Object Repository file is a spreadsheet with all the UI elements or controls details. 

The following screenshot represents Object Repository file and its contents


Field Description
Control NameDisplays all the UI element/ control name that were recorded in the scenario
Locator Displays the locators to find the UI elements
Control TypeDisplays the control types used to describe the nature and purpose of the UI elements
Control Identification TypeDisplays the locater type of the UI element
Feature NameDisplays the feature name
Page NameDisplays the page name 


To edit object repository file: On the Main Canvas, navigate to More Menu > Edit Object Repository and update the required field in the Object Repository file and save the details.

Generating Test Scripts

This section helps you to choose required  language and automation framework to generate test scripts using algoAF.

algoFramework is a tool in algoQA used to generate test scripts, which are set of instructions or code to automate test cases. The main capability is to generate test scripts for UI based functional test automation. 

To Analyze and Generate scripts

  1. After generating Test Cases, in the Test case generation pop-up window, click the link Go for Script Generation.
    Make sure you select the appropriate language, framework and the Report Type by clicking the settings icon in the script generation screen. Click Update.
  2. In the script generation screen, navigate to the appropriate folder and select the test case files and click Analyze button.

  3. Scripts will be generated.
    You can download the script to your desired location and proceed to the execution.

Execution of the scripts

When using TestComplete with algoQA, the generated test scripts will be stored in the same Test Case folder. You can download this script to your local machine to import this script into the TestComplete tool in the respective environment.
This algoQA generated script will work as a TestComplete project.


Tip: In the TestComplete script folder, double-click the project suite file with the extensions, such as .mds and .pjs to open the entire scripts in the TestComplete.


After opening the scripts in the TestComplete, you can review all the respective files related to the Python TestComplete framework before execution.


Execution Options

You can execute scripts in two ways:

  1. Using Feature Files: Open the respective Feature File which you want to execute in the TestComplete. You can either execute a single scenario or an individual step by right-clicking on the respective scenario outline or an individual step. You can also execute the whole Feature File by right-clicking on the respective file without opening it.

  2. Using Command Prompt: Alternatively, you can execute scripts using the command prompt, providing command-line instructions to run your tests. This command will launch TestComplete framework and start executing defined tags by opening the project with the help of the path mentioned as follows:

    Command line syntax example:
    The following command runs TestComplete, loads the MySuite.pjs project suite, commands TestComplete to execute the test items of the TestComplete project and updates the test results.

    TestComplete.exe "D:\script_folder\new script\TestComplete.pjs"  \p:TestComplete \tags:"@tagname" \r

    The following table represents command-line arguments:

    Key
    Description
    D: \script_folder\
    Specifies the path where the script is located
    \TestComplete.pjs
    Specifies the file_name that launches TestComplete framework and loads the specified project (.mds file) or project suite (.pjs)
    \p: project_name
    Specifies the project name
    \tags: "@tag_name"
    Specify the test case name, which corresponds to the tag assigned to the test case in the feature file. In the TestComplete tool, you can execute all those scenarios under this specified tag name.
    \r
    Commands TestComplete to execute tests provided by the project suite














Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article