Parameterizing Region Checkpoints

Applies to TestComplete 14.71, last modified on April 22, 2021

In TestComplete, region checkpoints verify that an object of the application under test or an arbitrary area inside an object is displayed correctly. This is done by comparing the actual image of the object or area with the baseline image stored in your test project.

Region checkpoints take parameters that specify the actual image to be verified and comparison settings (for example, pixel and color tolerance, comparison mask and so on). For detailed information on region checkpoint parameters, see the description of the Region Checkpoint keyword test operation or the description of the Regions.RegionCheckpointName.Check scripting method. The name of the baseline image used by the region checkpoint is specified by the checkpoint name.

In your tests you may want to parameterize your region checkpoints, that is, to replace their hard-coded values with variable values.

For example, if you want your region checkpoint to use various comparison settings during each test run, you can replace its hard-coded comparison parameters’ values with variable values you specify before you call the checkpoint. You can also replace the hard-coded name of the image that the checkpoint verifies with the parameter and then re-use the checkpoint in your tests to check multiple onscreen objects against the same baseline image.

The image below demonstrates two region checkpoints. One of them verifies the image of the object using the hard-coded name of the onscreen object to verify and the hard-coded values of comparison parameters, the other one uses the object’s name and values of comparison parameters stored in the keyword test parameters:

Parameterized Region Checkpoint operation

The sections below describe how to parameterize your region checkpoints:

In keyword tests

  1. Create a parameter (or parameters) that will pass the needed value to the checkpoint. It can be:

    For example, the image below shows the parameters of a keyword test:

    Creating a keyword test parameter to parameterize a checkpoint

    Click the image to enlarge it.

  2. In your keyword test, replace the hard-coded values of the checkpoint operation with the created parameters or variables:

    Parameterizing Checkpoint operation

    Click the image to enlarge it.

  3. Assign the needed value to the created parameters or variables:

    • If you use test parameters, set their values when you run your test:

      • If you run it as part of the project’s test items sequence, set the test parameters on the Test Items page of your project.

        Note: If you parameterize the object whose image the region checkpoint should verify, you will not be able to specify that parameter value on the Test Items page directly. You can specify it by using a variable that holds the needed object.
      • If you run your test from another test, set the parameter values when calling your test:

        Setting parameter value

        Click the image to enlarge it.

    • If you use test, project, or project suite variables, to set their values, you can use the Set Variable Value operation.

  4. Run the test with the needed parameter value assigned.

In scripts

  1. Define a parameter or variable that will pass the needed value (or values) to the checkpoint. It can be:

    For example, the code snippet below shows how to declare parameters of a script routine:

    JavaScript, JScript

    function ValidateRegion(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)
    {

      …

      Regions.wndNotepad.Check(Aliases.notepad.wndNotepad, false, false, 0, 0, "wndNotepad_Mask");

      …

    }

    Python

    def ValidateRegion(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam):
      …

      Regions.wndNotepad.Check(Aliases.notepad.wndNotepad, false, false, 0, 0, "wndNotepad_Mask")

      …

    VBScript

    Sub ValidateRegion(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)

      …

      Call Regions.wndNotepad.Check(Aliases.notepad.wndNotepad, false, false, 0, 0, "wndNotepad_Mask")

      …

    End Sub

    DelphiScript

    procedure ValidateRegion(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam);
    begin

      …

      Regions.wndNotepad.Check(Aliases.notepad.wndNotepad, false, false, 0, 0, 'wndNotepad_Mask');

      …

    end;

    C++Script, C#Script

    function ValidateRegion(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)
    {

      …

      Regions["wndNotepad"]["Check"](Aliases.notepad.wndNotepad, false, false, 0, 0, "wndNotepad_Mask");

      …

    }

  2. Replace the hard-coded parameters of the Regions.RegionCheckpointName.Check method with the created variables or routine parameters:

    JavaScript, JScript

    function ValidateRegion(onscreenObj,transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)
    {

      …

      Regions.wndNotepad.Check(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam);

      …

    }

    Python

    def ValidateRegion(onscreenObj,transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam):
      …

      Regions.wndNotepad.Check(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam);

      …

    VBScript

    Sub ValidateRegion(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)

      …

      Call Regions.wndNotepad.Check(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)

      …

    End Sub

    DelphiScript

    procedure ValidateRegion(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam);
    begin

      …

      Regions.wndNotepad.Check(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam);

      …

    end;

    C++Script, C#Script

    function ValidateRegion(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)
    {

      …

      Regions["wndNotepad"]["Check"](onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam);

      …

    }

  3. Assign the needed values to the parameters or variables:

    • If you use script parameters, you set their values when you call the routine, either from another script routine or as the project’s test item.

      For example, the code below shows how to run a parameterized script routine from another routine:

      JavaScript, JScript

      function Main()
      {

        …
        ValidateRegion(Aliases.notepad.wndNotepad, false, false, 0, 0, "wndNotepad_Mask");
        …
      }

      function ValidateRegion(onscreenObj,transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)
      {

        …

      }

      Python

      def Main():
        …
        ValidateRegion(Aliases.notepad.wndNotepad, False, False, 0, 0, "wndNotepad_Mask")
        …

      def ValidateRegion(onscreenObj,transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam):
        …

      VBScript

      Sub Main
        …
        Call ValidateRegion(Aliases.notepad.wndNotepad, False, False, 0, 0, "wndNotepad_Mask")
        …
      End Sub

      Sub ValidateRegion(onscreenObj,transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)
        …

      End Sub

      DelphiScript

      procedure ValidateRegion(onscreenObj,transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam);
      begin

        …

      end;

      procedure Main();
      begin

        …
        ValidateRegion(Aliases.notepad.wndNotepad, false, false, 0, 0, 'wndNotepad_Mask');
        …
      end;

      C++Script, C#Script

      function Main()
      {

        …
        ValidateRegion(Aliases["notepad"]["wndNotepad"], false, false, 0, 0, "wndNotepad_Mask");
        …
      }

      function ValidateRegion(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)
      {

        …

      }

    • If you use variables, set their values in the script before the script executes the checkpoint.

  4. Run the script with the needed parameter value assigned.

See Also

Region Checkpoints
About Region Checkpoints
Parameterizing Keyword Tests
Parameterizing Script Routines

Highlight search results