与其临渊羡鱼,不如退而结网!

为标准对象创建客户化GUI检查

上一篇 / 下一篇  2007-01-06 23:25:22 / 个人分类:Winrunner 技术

51Testing软件测试网nc pg1`h.e

默认情况下,WR为标准对象提供一些基本检查功能。但是,当现存的check功能不是很好满足自己需要的时候,就需要手动添加一些GUI检查点来完善。为标准对象添加属性检查的基本步骤如下:
h9g9]Yg/D01 为该检查创建捕获功能,以便确定预期结果和实际结果;
._6W R3d4@v-s02 为该检查创建比较功能,以便确定预期结果和实际结果;51Testing软件测试网F X:DE2{tL
3 注册使用该捕获功能和比较功能的检查;
x}'{:R:_Nw ]Z A04 将此新检查同标准对象类连接;
h\|:A$rg0U4c V05 设置默认检查;
vgC(H _ U0nw0下面为计算器的按钮添加一个 Size 属性的检查。给出一段简单代码,并对一些基本语法给予注释。

j4NRWc4~i&q'~M051Testing软件测试网l D4VR7\

脚本1:(完成了捕获功能和比较功能)
K7v9sk.|TuO0#Test Type:Compiled Module

(@A{q5D l+y051Testing软件测试网:B'z~g?4hXb

######################################################################51Testing软件测试网_f)MY*`AW d-G
#Descrīption: User-Define function using to capture size of a object
]V D#wN0######################################################################

A.Qh+W/Mm,R U051Testing软件测试网N+j9U1~(e3|U?2Z/gm

function size_capture(object, inout size)51Testing软件测试网w^ S y'WO4z!e:C
{51Testing软件测试网 o{*u#lo2fa
    auto height,width;
;KFw$zX0    obj_get_info(object, "height", height);  51Testing软件测试网Z:A-K8jm_
    obj_get_info(object, "width", width);51Testing软件测试网 ~D1O)L.s
    size = height * width;51Testing软件测试网's.W-N#\7fx5QGI,~
    return 0;51Testing软件测试网"__)k'|(I9?I
}

I ^Z*AX8w&e7G$K051Testing软件测试网uX"nVd!O-l

51Testing软件测试网x{1GVByX-_ x*u[
######################################################################
%x#NS\?h'Y0#Descrīption: User-Define function using to compare the actualResult and
/K1v{Zj0#the ExpectedResult,and return E_OK when successed,or else51Testing软件测试网p,~} U\&dQ1B6m^
#return E_DIFF.51Testing软件测试网-o] |;W'n!h9|
#Note: E_DIFF is the error code for "GUI verification missmatch found."You may use #the defualt_compare_func to do this.
:mF#v!_wZ:}0######################################################################51Testing软件测试网pQw(e$~;wRb&}

_;Z P]7H^J0public function com_result (in expected, in actual){
8yiB-]DK{!N KF0 if (expected == actual)51Testing软件测试网+X,~4Z"k-H],r
  return (E_OK);
0F;YZFh'D6mb)g0 else51Testing软件测试网$R2f:p$^?1x
  return (E_DIFF);51Testing软件测试网G4m9Ri!I'KJ
}

;z.Yt5HJk"D0

P*JO3g!xD{f0 51Testing软件测试网K!N-W'W$s9J8JY8N

51Testing软件测试网'}5r-fo\%Gz0x+b(n

脚本2:51Testing软件测试网j0wy5K+t{

{Ty3ocmP0load("C:\\size");51Testing软件测试网/[w$tdeT k1L2S

51Testing软件测试网{%T2h*Rp ?? oP

#注册使用该捕获功能和比较功能的检查
1N$W&k2N H/Auk0#Syntax: gui_ver_add_check(check_name, capture_function,comparison_funcion[,display_function][,type])51Testing软件测试网 |2mf~*e dE"N
#  use the display_function parameter only If you use the gui_ver_add_class #function to creating a GUI51Testing软件测试网/zJ*{ ^x l
#checkpoint dialog box with a custom user interface. Type: 1 for window, 0 for any #other GUI object
ts5KAP*x.Z0gui_ver_add_check ("Size","size_capture","com_result","",0);51Testing软件测试网-W;aN Z3[e!E~o

51Testing软件测试网CV4`:]he7IH6u

51Testing软件测试网"XvTl:R!RM
#将此新检查同标准对象类连接51Testing软件测试网OH#pee7~C4N|,l
#
/@%}Q1Z+c6E0Eo0o:P0#Syntax: gui_ver_add_check_to_class ( class, property_check_name );51Testing软件测试网5?bhC(h%B
#class is the name of either the MSW_class or the standard class with which
K` k+e0SG g0}~0#the check is associated.51Testing软件测试网[D%Sr\ {6E/@
#property_check_name is the name of the property check you defined using the
ntWkJ8V+x\0#gui_ver_add_check TSL function. The new property check will appear at51Testing软件测试网r/B;Q'p k{5Hq"SkJ
#the bottom of the list of properties displayed for the class in the GUI
fZ HES4S#ykR0#checkpoint dialog boxes.51Testing软件测试网M4C)p(Mr6MO Kc
#Note: you can associate the same property check with more than one class by #repeating this function for each GUI objcet class.
Z(~ H:ty#n P"De4o0gui_ver_add_check_to_class("push_button","Size");51Testing软件测试网M:Wm1wcSH

"^I_MK051Testing软件测试网p,l({ O!v ? d2]7~
#设置默认检查。
v(c4\,] btkK0#
r;w'z'E/| ` ^a0#Syntax: gui_ver_set_default_checks ( class, check_name1...check_namen );51Testing软件测试网t]gq@|`.ad
#. class is the name of either the MSW_class or the standard class for which51Testing软件测试网pW:J1m oZ(dD
#you want to set the default checks.51Testing软件测试网-sPo.h_.[6_"V
#. check_name1-n are the names of the property checks to be set as defaults.51Testing软件测试网{$fM@7?a/a8w z
#Note: use this function to define a custom property check as a default property #check, and it overwrites all previous default property #checks.So you must include #all the property checks that you want to set as defaults for the GUI object #class.Additonally, Using it to #define additional standard property checks as #default property checks.51Testing软件测试网P5\r'~jI7o$U
#Note that when you define more than one default property check, separate the #default property checks with spaces.
_uHC9q*?0gui_ver_set_default_checks ("push_button","Size");51Testing软件测试网8iU|E9k x&d

$ULE;wq,h6JD V0运行环境:WinXP+SP2,WR7.651Testing软件测试网!\9T7ys[T
参考文件:《WinRunner Customization Guide》

V9eR0O3]7e!}V0
相关阅读:

TAG: WinRunner

gp_jl的个人空间 引用 删除 gp_jl   /   2007-01-08 22:21:45
这个一般是在startup脚本中load相应的compiled module。然后,对push_button检查时就可以在 Check GUI 对话框的 Properties 中就可以看见这个检查点(位于标准检查点的下方)。如果不想使用这个检查点,不进行相应的load操作,Check GUI对话框中就不会出现这个用户自定义检查点了。所以,WR本身没有提供删除函数。
接受你的建议,把它导入论坛,看看大家都是怎样使用的,呵呵
dionysus的个人空间 引用 删除 dionysus   /   2007-01-08 11:07:17
这个具体怎么用呢?以后WR检查push_button时可以多出一个自定义的检查点?不是很明白
连接上自定义的后又怎样删掉呢?
把这篇文章导入论坛里吧,要不关注的人会少很多
 

评分:0

我来说两句

Open Toolbar