Automating Test cases Using TestComplete FrameworkDesktop Application Scraping Using TestComplete Desktop Scraper

Desktop Application Scraping Using TestComplete Desktop Scraper

This article explains how to scrape desktop applications using the Desktop Scraper extension in TestComplete. The scraper allows users to capture application controls and generate CSV files that can later be used in algoQA for scenario creation, test case generation, and test script generation.

Prerequisites

Create a New TestComplete Project

  1. Launch TestComplete.
  2. Navigate to File > New > New Project.
  3. Enter the required project details: Project Name, Project Location, Scripting Language.
  4. Click Finish.
    New Project dialog with Project name, Project location, Scripting language fields and Finish button

The project will be created and saved in the specified location.

Add the Scraper Code

Open the newly created project and add the following code to the workspace:

def ElementScraper():

buttons = MkSet(mbYes, mbNo)

AlgoScraper.StartElementScraping( Win32API, BuiltIn, buttons, mrYes )

def PageScraper():

buttons = MkSet(mbYes, mbNo)

AlgoScraper.StartPageScraping( BuiltIn, buttons, mrYes, Options )

TestComplete script editor showing ElementScraper and PageScraper Python function definitions

Installing the Scraper Extension

Download TestComplete algoScraper V1.4 from algoQA downloads, the algoScraper.tcx file will be available in same folder.

  1. Copy the file to the TestComplete Script Extensions folder.

Example location: C:\Program Files (x86)\SmartBear\TestComplete 15\Bin\Extensions\ScriptExtensions

The installation path may vary depending on the TestComplete installation on each system. However, the folder structure remains the same.

  1. Restart TestComplete.

Verify Installation

To verify that the extension has been installed successfully:

  1. Open TestComplete.
  2. Navigate to File > Install Script Extensions.
  3. Confirm that Scraper Extensions is listed.

Scraping Methods

The Desktop Scraper supports two types of scraping:

  1. Element-by-Element Scraping
  2. Page Scraping
    TestComplete workspace code editor showing ElementScraper and PageScraper function definitions

Element-by-Element Scraping

Element-by-Element Scraping: Use this method when you want to capture individual controls from an application.

Perform the following:

  1. Select Element Scraper from the available options.
  2. Click Run.
  3. Enter a screen name when prompted.
    Enter Screen Name dialog with Page1 field and OK, Cancel buttons
  4. Open the target application (for example, Calculator).
  5. Move the cursor over the required control.
  6. Press the Ctrl key.

The selected control will be highlighted in red and captured by the scraper.

Stopping or Continuing Scraping

  1. Press the Esc key.
  2. A confirmation dialog appears: Do you want to stop scraper?
    TestComplete dialog asking Do you want to generate csv file with Yes and No buttons

To Continue Scraping Another Screen

  1. Click No.
  2. Enter a new screen name. (Example: Weather)
  3. Open the new application.
  4. Continue scraping controls using the Ctrl key.

To Stop Scraping

  1. Click Yes in the confirmation dialog.
  2. Scraping will stop.
  3. A success message will display the generated CSV location.

Generated Output: A file named Scraped_Elements.csv is generated in the project folder.

The CSV contains information such as:

  • Control Type
  • Control Name
  • XPath
  • Page Name
  • Feature Name
  • Node Name

Do not open the CSV file while scraping is in progress.

Page Scraping

Use this method when you want to scrape an entire application page at once.

Ensure the target application is already open before starting page scraping.

Perform the following:

  1. Select Page Scraper.
  2. Click Run.
  3. Enter a screen name. (Example: Calculator)
    Enter Screen Name dialog with Page1 field and OK, Cancel buttons
  4. Click OK.
  5. Within 5 seconds, navigate to the target application window.
    Scraper toolbar tooltip showing Delays script execution for 5000 milliseconds with progress bar

The scraper automatically captures the currently active window.

Parent Name Confirmation

After capturing the page, a dialog appears: Please confirm or edit the parent name.

  1. Verify the parent name.
  2. Modify it if required.
  3. Click OK.
    Parent Name Confirmation dialog with Process Name field showing ApplicationFrameHost

Continue or Stop Scraping

After the page is captured, a dialog appears: Do you want to stop scraper?

TestComplete dialog asking Do you want to generate csv file with Yes and No buttons

To Continue

  1. Click No.
  2. Enter a new screen name. (Example: Weather)
  3. Navigate to the next application.
  4. Repeat the process.

To Stop

  1. Click Yes.
  2. The scraper generates the output CSV and displays the file location.

Generated Output: A file named Scraped_Page.csv is generated in the project folder.

The CSV contains:

  • Control Type
  • Control Name
  • XPath
  • Page Name
  • Feature Name
  • Node Name

Finding the Correct Parent Name

In some applications, the parent name may not be correct.

When prompted for the parent name confirmation:

  1. Open Object Browser in TestComplete.
  2. Locate the target application in the object tree. (Example: Microsoft.WindowsCalculator)
  3. Copy the correct parent name from the object hierarchy.
  4. Paste it into the Parent Name Confirmation dialog.

Parent name confirmation is required only for applications where the process name is not identified correctly.

Using the Scraped Data in algoQA

After the CSV file is generated:

  1. Create a new project in algoQA.
  2. Upload the generated scraped CSV file.
  3. Continue with:
    • Scenario Recording
    • Scenario Generation
    • Test Case Generation
    • Test Script Generation

The uploaded scraped data will be used to create the application model and accelerate test automation activities.