技术只有在交流分享中才能更上一层楼!
复杂的事简单做。
简单的事认真做。
认真的事重复做。
重复的事创造性做。
TC中如何添加对象及比较对象
上一篇 /
下一篇 2008-05-02 12:26:43
/ 个人分类:TestComplete
8~7H"o!e|"XnI0在自动化的过程中,经常需要对两个对象(或属性)进行比较,看否前后一致,来判断某个对象是否被修改过,而在TC中就提供了这样的方法:Objects.Compare(Object1,Object2)
F7NH&?|#K'k6r0Ro n7_'R0首先,我们要添加两个对象,可以在脚本录制或回放过程添加,也可以在这之前添加,通过以下方法可以添加对象:51Testing软件测试网9O.B5m2}
N
51Testing软件测试网:d)mqt
J//添加对象属性方式51Testing软件测试网8^;F4\B5K!~`%f0lB
//1.Adding property collections from the Object Browser
c`puJ)X%Ury0//2.Adding property collections from the Object Properties window51Testing软件测试网`s;NU$}%xp
//3.Adding property collections from the Tools toolbar51Testing软件测试网`/AC;MU,xD(F
//4.Adding property collections during recording51Testing软件测试网;j1Da@.Xz2E.}iGM#B
g
//5.Adding property collections from scrīpts51Testing软件测试网"~ Ca`$`zX
//6.Adding property collections from the Objects editor
.uc@@"G t0//7.Adding property collections from the Project Explorer
_Wta2[0N`p R!y#]}0接下来就是如何比较了,这些方法具体使用如下:
0JB4{R
i"a051Testing软件测试网O
ub2s&? M-H//在脚本中添加对象属性
2l$D(WNG|Do'j ug0procedure AddObjectfromscrīpt;
kF},py#}!H0var
0e/O iT,e|~&y0 w, PropertyNames, CollectionName : OleVariant;51Testing软件测试网"F%e6X!S]"^
begin
]_ Z{'u
R }Q8om0 //激活窗体51Testing软件测试网5hO!gA%o$k
Aliases.TCSampleForm.Activate;
Mg8C\"A)k
D0 //保存当前激活的窗体对象51Testing软件测试网%US$z_X+Hh
w := Sys.Desktop.ActiveWindow();
Yy'[,q1FL0 //设置将要保存的属性名称 51Testing软件测试网`nS%CY3["D&H\
PropertyNames := 'WndCaption';51Testing软件测试网@([4_q4Y"P&r
OP
//设置在Object集合中保存的名称
;k8N)~1lw8a U0 CollectionName := 'TCSampleFormName';
9_1T;tVV-~O|;E0 //保存激活窗体对象属性
c]Z
s"~ S
dSa0 Objects.Save(w, CollectionName,PropertyNames);
J \~zWQ&[%a8f0end;51Testing软件测试网q;Y
XWN#l'v@j
}0`Rt?i:y0//比较操作数1的对象属性名称是否改变
0z!K\wR'{ L ^0procedure CompareOperend1;
f%Gp7U2X"L0begin51Testing软件测试网6f_x%faG
if not Objects.Compare(Aliases.TCSampleOperand1, 'TCSampleOperand1') then51Testing软件测试网2UP A#b
Z#E
showmessage('Objects are not identical.'+Objects.LastError)
-O
C[S[c7\ Qyw|
i0else showmessage('Objects are identical.');51Testing软件测试网){r|;]B]S'R
end;
6?@&P%W9W'a0Wn+Sw`T0注,以上脚本都很简短,是因为对象做了别名映射。
C Y.V^Q#k2V09~I2n7M,b%C,b8RY~0 51Testing软件测试网Ux%eEI
相关阅读:
- TestComplete 5 / 6 的选项设置介绍【 出自Terry Young 】 (jely, 2008-2-02)
- TestComplete DDT (Data-driven Test) 数据驱动测试简单实例 (terryyoung, 2008-2-03)
- TestComplete 5+ 与 Borland Starteam 的整合 (terryyoung, 2008-2-03)
- TestComplete 5+ 与 Borland Starteam 的整合【出自Terry Young】 (jely, 2008-2-04)
- TestComplete DDT (Data-driven Testing) 数据驱动测试介绍和简单实例【Terry Young】 (jely, 2008-2-04)
- TestComplete 6.11 內 Code Explorer 的小改良:Unit Metrics (terryyoung, 2008-2-06)
- TestComplete 7 官方意见调查 (terryyoung, 2008-2-06)
- TestComplete 5.x 快捷键总览 (Keyboard Shortcuts) (terryyoung, 2008-2-16)
- TestComplete测试计算器实例 (qiguojie, 2008-4-30)
- TC中Add File & Compare File使用介绍 (ZERONG.HE, 2008-5-02)
收藏
举报
TAG:
TestComplete