VerifyBitmap Method




Verifies that the screen image matches a saved bitmap of the image.


window.VerifyBitmap(sBitmapFile[, Rect] [, sMaskFile])
Variable Description
sBitmapFile The name of the file to compare against the current state of the screen (typically a baseline). If you use the default bitmap location when you capture a bitmap (you did not specify a file location, only the name), the bitmap is saved in the working directory for the Agent on the machine that runs the Agent. In this case, you do not need to specify the file path, just the filename when you verify the bitmap. If you use a relative path or absolute path when you capture the bitmap, you must specify the full path for the bitmap to verify it. Append .png to the filename to save the bitmap as a PNG. STRING.
Rect Optional: The area to capture, relative to the window. If you omit Rect, Silk Test Classic captures the entire window. RECT.
sMaskFile Optional: The name of the file containing a mask for the comparison. STRING.


VerifyBitmap compares the specified window or screen region against the bitmap in sBitmapFile. Note that if you are doing distributed testing, sBitmapFile resides on the target machine, not on the host.

Before comparing the image on the screen against the bitmap in the file, VerifyBitmap attempts to get a stable copy of the bitmap. Silk Test Classic captures a stable copy by capturing the bitmap multiple times, waiting the interval specified with the OPT_BITMAP_MATCH_INTERVAL option between snapshots. You specify the number of images that must match for the bitmap to be considered stable with the OPT_BITMAP_MATCH_COUNT option. Silk Test Classic attempts to capture a stable bitmap up until the time limit set with the OPT_BITMAP_MATCH_TIMEOUT option. If the application does not generate a stable version of the bitmap, Silk Test Classic raises the exception E_BITMAP_NOT_STABLE.

If sBitmapFile and the current state of the specified window or screen region do not compare as equal, VerifyBitmap saves a representation of how they differ in sBitmapFile.rmp and raises the exception E_BITMAPS_DIFFERENT. You can specify a pixel tolerance below which differences between bitmaps are ignored, using the OPT_BITMAP_PIXEL_TOLERANCE option.

You specify the coordinates to capture with the argument Rect, which is a record of the RECT data type:

VerifyBitmap interprets the coordinates (0,0) as the top-left corner of the window’s frame. To capture a bitmap of a window’s client area only, specify window.ClientArea as the window to capture.

If the screen image and the saved bitmap file use different color tables, Silk Test Classic prints the warning E_BITMAPS_DIFF_COLORTABLE. If the screen image and the saved bitmap file have different dimensions, Silk Test Classic prints the warning E_BITMAPS_DIFF_SIZE. If the bitmaps are not exactly the same but their differences are below the allowable tolerance level (set with the OPT_BITMAP_PIXEL_TOLERANCE option), Silk Test Classic prints the warning E_BITMAPS_ALMOST_MATCH.

The Open Agent and Classic Agent capture bitmaps in different color depths. By default, the Open Agent captures bitmaps using the current desktop settings for color depth. The Classic Agent captures bitmaps as 24-bit images. If you create a mask file for the captured bitmap using the Bitmap tool that comes with Silk Test Classic, the mask file is saved as a 24-bit bitmap. If the bitmap mask file does not have the same color depth as the bitmap that you capture, an error occurs. To ensure that VerifyBitmap functions do not fail due to different color-depth settings between the captured image and the mask image, ensure that the bitmaps have the same color depth.

To view, capture, and compare bitmaps, and to create monochrome mask files, use the Silk Test Bitmap Tool.

If VerifyBitmap returns an error, Silk Test Classic creates a link that opens the Silk Test Bitmap Tool to show the differences. However, if VerifyBitmap was called with a relative pathname, the Silk Test Bitmap Tool cannot open the file. Therefore, it is recommended that you use absolute paths with VerifyBitmap.

You must specify a value for the Rect argument if you specify the sMaskFile argument. If there is no actual value for Rect, specify the constant NULL.


Elements.VerifyBitmap ("C:\Program Files\Silk\Silk Test\Projects\texteditor\bitmap.bmp")