|
Description
How to validate a checkmark, checkbox, or other image next to a list item using the standard Winrunner API.
Solution
Many times there is a checkbox, checkmark or other image next to to a list item which needs to be validated. One way to do this is to use check_pic_area located in the CSO library (see Knowledge Base Article 8572 How to get the state of a checkbox in a list control). However you can do the same thing using obj_check_bitmap, the standard Winrunner API call to validating images.
Here is a function for doing this:
#######################################################
#
# list_checkForCheckMark
# arguments:
# list - list object
# item - list item name
# image - name of the expected image file
# caveats: list item being checked for must be displayed and the list must not
# be scrolled down.
#
#######################################################
function list_checkForImage(list,item,image)
{
auto item_num;
list_get_item_num("SysListView32",item,item_num);
obj_check_bitmap("SysListView32",image,1,0,1+(17*(item_num + 1)), 17, 18);
}
and here is the call:
list_checkForImage("SysListView32","V8_5.dgn","redcheck");
You may need to modify the coordinates in order to get the image correctly. You will also need to capture the expected image. The easiest way to do so is to create a bitmap checkpoint for the area (Create->Bitmap Checkpoint->For Screen Area), and then rename the captured image (found in the <name of test>/exp/<name of test> directory) to whatever the picture is. You may have to do this several times to get the image and the coordinates to line up exactly! Bitmaps do not have to be called Img1.bmp, Img2.bmp... as they are by default, so renaming bitmap images to what they picture makes a better self-documenting code. |
|