The Regions collection of the Stores project item contains images that can be used during testing, for example, for comparison purposes.
You may need to update a stored image used by a Region checkpoint for image comparison in order for the checkpoint to pass.
TestComplete allows updating stored images from scripts and keyword tests by using the Compare
method of the Regions
object or the Check
method of the Region
object or by using Region checkpoints. Usually, the methods and Region checkpoints are used to compare two images, but they can also replace a stored image with the specified one instead of comparing them.
In order to make it possible, enable the update feature for the desired stored image:
-
Enable the Update regions option in the Stores settings.
-
Check the Update flag of the desired stored image in the Regions editor.
The following code demonstrates how to use the Compare
method to update stored images:
JavaScript, JScript
var wnd = Sys.Desktop.ActiveWindow();
// Replaces MyStoredImage with wnd instead of comparing them
Regions.Compare ("MyStoredImage", wnd);
Python
wnd = Sys.Desktop.ActiveWindow()
# Replaces MyStoredImage with wnd instead of comparing them
Regions.Compare ("MyStoredImage", wnd)
VBScript
Set wnd = Sys.Desktop.ActiveWindow
' Replaces MyStoredImage with wnd instead of comparing them
Regions.Compare "MyStoredImage", wnd
DelphiScript
var wnd: OleVariant;
…
wnd := Sys.Desktop.ActiveWindow;
// Replaces MyStoredImage with wnd instead of comparing them
Regions.Compare ('MyStoredImage', wnd);
C++Script, C#Script
var wnd = Sys["Desktop"]["ActiveWindow"]();
// Replaces MyStoredImage with wnd instead of comparing them
Regions["Compare"]("MyStoredImage", wnd);
The following code demonstrates how to use the Check
method in your scripts to update stored images:
JavaScript, JScript
var wnd = Sys.Desktop.ActiveWindow();
// Replaces MyStoredImage with wnd instead of comparing them
MyStoredImage.Check (wnd);
Python
wnd = Sys.Desktop.ActiveWindow()
# Replaces MyStoredImage with wnd instead of comparing them
MyStoredImage.Check (wnd)
VBScript
Set wnd = Sys.Desktop.ActiveWindow
' Replaces MyStoredImage with wnd instead of comparing them
MyStoredImage.Check wnd
DelphiScript
var wnd: OleVariant;
…
wnd := Sys.Desktop.ActiveWindow;
// Replaces MyStoredImage with wnd instead of comparing them
MyStoredImage.Check (wnd);
C++Script, C#Script
var wnd = Sys["Desktop"]["ActiveWindow"]();
// Replaces MyStoredImage with wnd instead of comparing them
MyStoredImage["Check"](wnd);
To update images from keyword tests, use the Region Checkpoint operation or call the Regions.Check
or Regions.Compare
method by using the Call Object Method, Run Code Snippet or Run Script Routine operation.
Note: | Stored images used by Region checkpoints for image comparison can also be updated from test logs. For information on how to do this, see Updating Region Checkpoints. |