技术只有在交流分享中才能更上一层楼! 复杂的事简单做。 简单的事认真做。 认真的事重复做。 重复的事创造性做。

TC中Regions对象的使用介绍

上一篇 / 下一篇  2008-05-03 11:02:52 / 个人分类:TestComplete

j6Kjo#I(O0在TC中,提供了一个Regions对象集合,专门管理图像对象,可以通过以下方法添加图像对象到Regions集合中:51Testing软件测试网y r^M c:r

51Testing软件测试网A%g-g~0yrQ7|

//添加图像方式:51Testing软件测试网3Gao!xMP;e
//1.Add images from the Regions editor51Testing软件测试网$v&mX!Eu.u
//2.Add images from the Project Explorer
?3` a`+C_6w}0//3.Add images from the Image Viewer
%l;d gK r'O Q.SZL0//4.Add images during recording
`BD|^*Qa} hB0//5.Add images from scrīpts51Testing软件测试网Uj.p&D~X

51Testing软件测试网8Z,\9m6NfsT}

Regions对象封装了几个常用的方法,如Regions.AddPicture(添加图像)、Regions.GetPicture(获取图像)、Regions.FindRegion(查找图像)、Picture.Find(查找图像)等,具体使用如下:

$mjF*R9c0

Q7O-N3Z1c+T9z0//在脚本中添加图像51Testing软件测试网:`[uz/dm Q
procedure AddImageFromscrīpt;
]^e9gp-L~0begin
.d?}*W'x0w)C0  //添加主窗体图像
"b-z1Nji0  Regions.AddPicture(Aliases.TCSampleForm,'TCSampleForm');51Testing软件测试网R,C?4h(d4J
  //添加主窗体中操作数1的图像
^3\HeJ5r0  Regions.AddPicture(Aliases.TCSampleOperand1,'TCSampleOperand1'); 
[l:JA`WN0end;51Testing软件测试网!r:} b+N K,K

S[-g8lm/ruc0//回放脚本过程中截取图像与在Regions集合中的图像进行比较51Testing软件测试网5l-Z T{.z|+t&\
procedure CompareImage_Playback;    51Testing软件测试网6rt\vZ|.X z
begin
S3o*m n.F0  if not Regions.Compare('TCSampleFormChangeName', Aliases.TCSampleForm) then51Testing软件测试网hO(Y,Df@A
    Log.Error('The compared regions are not identical.', Aliases.TCSampleForm.Name);  
-rAVT|:P0end;51Testing软件测试网2ayQn)?T c)d_

wE\2}%L J,B3p0//Regions集合中两个图像进行比较
0t;K3Mk1[N a*g0procedure CompareImage_Regions;  51Testing软件测试网 R{TS5YE.}^
begin 51Testing软件测试网.SP:a8_[,r[[3U/fE"m
  if not Regions.Compare('TCSampleFormChangeName', 'TCSampleForm') then51Testing软件测试网;r:@;_ I$A
    Log.Error('The compared regions are not identical.', 'TCSampleForm');51Testing软件测试网0Z6NW&u5n0A;f c
end;51Testing软件测试网]4yg$^;_ V$H;M

VQ@BSs9T0//使用Picture对象比较两个图像  
6?7\y U)b2I4Y0O0procedure CompareImage_Picture;
7HdT-IE WC0var pict1,pict2 : olevariant;
o$F4`4h]L6ld4`5s0begin   51Testing软件测试网 J.|3D0FW;|xG
  pict1 := Regions.GetPicture('TCSampleForm');51Testing软件测试网)ShQ@m ^P$]:c
  pict2 := Regions.GetPicture('TCSampleFormChangeName');51Testing软件测试网;iE ?+]#k^Nl
  if not pict1.Compare(pict2) then51Testing软件测试网~+iR1y%B~4~n(m
    Log.Error('The compared regions are not identical.');    
@ Y p)pbV0end;

(xv Crl!| }0 51Testing软件测试网!ng+f;Gp)m%N&L)r6G-A

//使用Regions对象的FindRegion方法查找图像  51Testing软件测试网2O @4l1hSx| _+stw
procedure FindImage_Regions; 51Testing软件测试网 ^F-_ CT%J"aj6A
var pict1,pict2 : olevariant;
f'[ocr!_ Pw0begin  
a$j&E$b W+H0  if (Regions.FindRegion('TCSampleOperand1','TCSampleForm') = nil) then51Testing软件测试网4z:K1\#fAd}3p.D
    Log.Warning('Picture not found.');     51Testing软件测试网6O4dK"rN(|u
end;51Testing软件测试网?#{.yG eP Q

P'c,^brCO0//使用Picture对象的Find方法查找图像 51Testing软件测试网 ~+mev*YG
procedure FindImage_Picture; 51Testing软件测试网;Yn9|`YW;[ |
var pict1,pict2 : olevariant;
uY/UO yvt0begin  
r$j@w5i|@a~ f0  pict1 := Regions.GetPicture('TCSampleForm');51Testing软件测试网.U ceS!n\+m n[` S
  pict2 := Regions.GetPicture('TCSampleOperand1');51Testing软件测试网)IG*^.`| g
  if (pict1.Find(pict2) = nil) then
-dJk.D N5^;facA0    Log.Warning('Picture not found.');       
^!e6|#V6wnN5{'q-J0end;51Testing软件测试网-^ Yas!k#zMd

.\ lGz V}'Q0

TAG: TestComplete

 

评分:0

我来说两句

日历

« 2024-04-24  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 22060
  • 日志数: 36
  • 文件数: 1
  • 建立时间: 2007-11-13
  • 更新时间: 2008-09-21

RSS订阅

Open Toolbar