CheckImage Method

Applies to TestComplete 14.30, last modified on November 21, 2019
This method is obsolete. See the Remarks section below.

Description

Checks whether a control specified by its image in the Image Repository is currently displayed on the mobile device’s screen and posts the result to the test log.

To perform the check without posting any test log messages, use the Exists method.

Declaration

TestObj.CheckImage(MobileDevice)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
MobileDevice [in]    Optional    A Device object Default value: 0   
Result Boolean

Applies To

View Mode

This method is available in the Object Browser panel and in other panels and dialogs in both Basic and Advanced view modes.

Parameters

The method has the following parameter:

MobileDevice

The AndroidDevice or the iOSDevice object that specifies the device on whose screen the method will search for the control’s image. You can access the required device by calling the Mobile.Device method.

If the parameter is omitted, the method will search for the control’s image on the device that was made current by calling Mobile.SetCurrent in your script code, or by executing the Select Device or Device Loop operation in your keyword test.

Result Value

If the control’s image was found on the device’s screen, the method returns True and posts a checkpoint message () to the test log. Otherwise, the method returns False and posts an error message () to the log.

Remarks

  • This method is obsolete. It is supported for backward compatibility only.

  • The CheckImage method searches for the image pixel by pixel. For the search to be successful, the whole control should be visible on the screen. If the control is visible partially, or if it is overlapped by some other image (for instance, by a menu), the method returns False.

  • To check whether the PC desktop shows a needed image, you can add the image to the Stores | Regions collection and use the Regions.RegionCheckpoint.Check method.

Example

The following code snippet checks the mobile device screen for the Button_Equal control, reports the results to the test log and, if the given control was found, simulates touch action over it:

JavaScript, JScript

...
if (ImageRepository.calculator.Button_Equal.CheckImage())
  ImageRepository.calculator.Button_Equal.Touch();
...

Python

# ...
if ImageRepository.calculator.Button_Equal.CheckImage():
  ImageRepository.calculator.Button_Equal.Touch()
# ...

VBScript

...
If (ImageRepository.calculator.Button_Equal.CheckImage) Then
  ImageRepository.calculator.Button_Equal.Touch()
End If
...

DelphiScript

...
if (ImageRepository.calculator.Button_Equal.CheckImage()) then
  ImageRepository.calculator.Button_Equal.Touch();
...

C++Script, C#Script

...
if (ImageRepository["calculator"]["Button_Equal"]["CheckImage"]())
  ImageRepository["calculator"]["Button_Equal"]["Touch"]();
...

See Also

Testing Android Applications
Exists Method
ImageSetItem Object

Highlight search results