聪明文档网

聪明文档网

最新最全的文档下载
当前位置: 首页> GetTOProperty和GetROProperty

GetTOProperty和GetROProperty

时间:2012-02-27 16:51:53    下载该word文档

GetTOProperty和GetROProperty

(2010-12-10 14:55:46)

word/media/image1.gif转载▼

GetTOProperty和GetROProperty都用于取出对象的某个具体属性的值,它们的语法和用法几近相同,唯一的区别就是GetTOProperty取出的是录制对象的属性值,GetROProperty取出的是在回放过程中运行的对象的属性值.

 

GetTOProperties,是指取出录制对象的所有属性。

 

GetTOPropertyGetROProperty语法都是:

object.GetTOProperty(Property)

或者是:

object.GetROProperty(Property)

其中Property,对象的属性,是必填项

 

GetTOProperties的语法为:

object. GetTOProperties

 

实例:

 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"

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

 

为了便于记忆,有人给出了这样的说法,感觉很不错,共享给大家:

 

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",或者为"取消"。

 

另外,除了这里讲了GetTOPropertyGetROProperty还有GetTOProperties,还想对上面代码中另外一个说明一下,就是ChildObjects方法,将所有符合Descrīption对象描述的特征的那些对象从Window("Flight Reservation").里面取出来,赋值给winedites,于是winedites就有了一个count属性,存储的是满足这个对象描述的对象的个数,于是,你想遍历每个对象的话,就可以用循环进行遍历了。

免费下载 Word文档免费下载: GetTOProperty和GetROProperty

  • 29.8

    ¥45 每天只需1.0元
    1个月 推荐
  • 9.9

    ¥15
    1天
  • 59.8

    ¥90
    3个月

选择支付方式

  • 微信付款
郑重提醒:支付后,系统自动为您完成注册

请使用微信扫码支付(元)

订单号:
支付后,系统自动为您完成注册
遇到问题请联系 在线客服

常用手机号:
用于找回密码
图片验证码:
看不清?点击更换
短信验证码:
新密码:
 
绑定后可用手机号登录
请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系 在线客服