51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1821|回复: 0
打印 上一主题 下一主题

WinRunner:validating images in list items using obj_check_bi

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2006-10-30 14:35:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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.
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-10-6 06:01 , Processed in 0.070926 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表