查看完整版本: GetTOProperty、GetROProperty、GetTOProperties的区别

qixiafeng 2007-3-9 11:10

GetTOProperty、GetROProperty、GetTOProperties的区别

GetTOProperty和GetROProperty都用于取出对象的某个具体属性的值,它们的语法和用法几近相同,唯一的区别就是GetTOProperty取出的是录制对象的属性值,而GetROProperty取出的是在回放过程中运行的对象的属性值.
[font=新宋体][color=#000000]GetTOProperties,是指取出录制对象的所有属性。[/color][/font]
GetTOProperty和GetROProperty语法都是:
object.GetTOProperty([i]Property[/i])
或者是:
object.GetROProperty([i]Property)[/i]
其中[i]Property[/i],对象的属性,是必填项.
[font=新宋体]GetTOProperties的语法为:
[/font][font=Courier New]object.[/font][font=新宋体]GetTOProperties[/font]
[font=新宋体]实例:[/font]
[font=新宋体]Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "training"
Dialog("Login").WinEdit("Agent Name:").Type  micTab
Dialog("Login").WinEdit("Password:").SetSecure "429376f06698f739df8bb1c09eab3d78dee316f7"
Set TableDesc = Dialog("Login").WinEdit("Password:").GetTOProperties
Properties=TableDesc.Count
reporter.ReportEvent micdone,"属性数目",Properties
If Dialog("Login").WinEdit("Password:").GetROProperty("attached text")="Password:" then
reporter.ReportEvent micdone,"name控件","存在"
else
reporter.ReportEvent micdone,"name控件","不存在"
end if
If Dialog("Login").WinEdit("Password:").GetTOProperty("attached text")="Password:" then
reporter.ReportEvent micdone,"name控件2","存在"
end  if
Dialog("Login").WinButton("OK").Click
'did the flight reservation window appear?
Window("Flight Reservation").Check CheckPoint("Flight Reservation")
Set Mydes=Descrīption.Create()
Mydes("attached text").value="Name:"
Mydes("nativeclass").value="Edit"[/font]
[font=新宋体]Set winedites=Window("Flight Reservation").ChildObjects(Mydes)
NoOfChildObjs =winedites.Count
For Counter=0 to NoOfChildObjs-1
if(Counter=0) then
       winedites(Counter).Set "ON"
  end if
Next[/font]

qixiafeng 2007-3-9 16:34

恩,不错,总结的挺好,再接再励!
Fight!!

红狐 2007-3-9 16:42

恩,不错,总结的挺好,再接再励!
Fight!!

qixiafeng 2007-3-9 16:45

多谢红狐

呵呵,先有自勉,后有他勉,不错不错

红狐 2007-3-9 16:51

不用谢不用谢,看一遍加深印象一遍

BiSheng 2007-3-9 18:41

今天还“打架”了呢,再次加深学习了!

rickyzhu 2007-3-9 18:45

一个是动态的,一个是静态

也就是一个是录制时候的值,另外一个是运行时候的值.

多谢作者拿出来跟大家分享,我也是前阵子才发现这个的.

yabest 2007-3-22 11:29

TO是仓库文件里的仓库对象,RO是被测软件的实际测试对象,两者是不同的对象,是独立的。

QTP是通过TO来寻找和操作RO的,所以TO里必须含有RO的特征,这是两者相似的地方。

TO的属性可以在录制时抓取RO的特征属性得来,也可以在脚本运行时通过SetTOProperty来随意更改,通过GetTOProperty来读取。

RO的属性可以通过GetROProperty来读取。没有SetROProperty,要修改RO属性,只能通过对象具体的Method。

TO的属性值和对应RO的属性值并不一定相同,TO的属性值可以包含通配符和多种可能的RO属性值。
如Cancel按钮,为了同时匹配中英文,它的TO属性值为"Cancel|取消",它的RO属性值则是确定唯一的,或者为"Cancel",或者为"取消"。

详见精华区里的帖子 [url=http://bbs.51testing.com/thread-13554-1-1.html]http://bbs.51testing.com/thread-13554-1-1.html[/url]

[[i] 本帖最后由 yabest 于 2007-3-22 11:40 编辑 [/i]]

alanxzg 2007-5-11 17:41

good

lyscser 2007-5-11 22:40

呵呵,还是不错滴

higkoo 2007-5-13 09:13

答案你都写出来了

“GetTOProperty取出的是录制对象的属性值,而GetROProperty取出的是在回放过程中运行的对象的属性值.”

答案就是上述这句话了!


录制完成后,库里就生成了一个固定值,就是TO。
回放过程这个值可能会改变,运行过程取值即为RO。


打个不适当的比方:

  你投资100万,这一百万就是TO。
  投资是有风险的,你可能赚,可能亏,实际剩下的就是你的RO了,RO是不断变化的。

higkoo 2007-5-13 09:14

本帖已经被作者加入个人空间

我想请问,怎么把帖加到自己的个人空间啊?sdlkfj5

wish_luckyman 2007-6-22 18:07

深奥,努力学习中

heqingbluesky 2008-1-22 14:29

明白了,学习了.

lxm_lxm 2008-10-13 15:10

好东西,收藏了,谢谢分享!
页: [1]
查看完整版本: GetTOProperty、GetROProperty、GetTOProperties的区别