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:
The sections below describe how to parameterize your region checkpoints:
In keyword tests
-
Create a parameter (or parameters) that will pass the needed value to the checkpoint. It can be:
-
Test parameters. You create them on the Parameters page of your test.
-
Keyword test variables. You create them on the Variables page of your test.
-
Project or project suite variables. You can create them on the Variables page of your project or project suite respectively.
For example, the image below shows the parameters of a keyword test:
-
-
In your keyword test, replace the hard-coded values of the checkpoint operation with the created parameters or variables:
-
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 in the Execution Plan editor 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 in the Execution Plan editor 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:
-
-
If you use test, project, or project suite variables, to set their values, you can use the Set Variable Value operation.
-
-
Run the test with the needed parameter value assigned.
In scripts
-
Define a parameter or variable that will pass the needed value (or values) to the checkpoint. It can be:
-
Script routine parameters.
-
Script variables.
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 SubDelphiScript
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");
…
} -
-
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 SubDelphiScript
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);
…
} -
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 SubDelphiScript
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.
-
-
Run the script with the needed parameter value assigned.
See Also
Region Checkpoints
About Region Checkpoints
Parameterizing Keyword Tests
Parameterizing Script Routines