QTP的Run-time Object与Test Object 属性之间的区别

本文详细解释了QTP中Run-timeObject与TestObject的区别,包括它们各自的属性和方法,以及如何在自动化测试脚本中使用这些对象。

TIB自动化测试工作室  http://www.cnblogs.com/testware/      

QTP的Run-time Object与Test Object 属性之间的区别  

用object spy查看测试对象时,有runtime object properties 和 test object properties两种,那么它们有什么区别呢?   

从QTP的帮助文档可以看出Run-time Object Properties与Test Object Properties之间的区别:

(1)Run-time Object Properties / Run-time Object Methods    Displays the run-time (native) object properties or methods associated with the object selected in the Object Spy's object hierarchy tree. Note that the label changes depending on whether the Properties or Methods tab is selected. You can use the Object property to retrieve or activate run-time properties and methods displayed in the Object Spy. For more information, see Retrieving Run-Time Object Properties and Activating Run-Time Object Methods.      

(2)Test Object Properties / Test Object Methods    Displays the test object properties or methods associated with the object selected in the Object Spy's object hierarchy tree. Note that the label changes depending on whether the Properties or Methods tab is selected. You can use the GetTOProperty and SetTOProperty methods to retrieve and set the value of test object properties for test objects in your test. You can use the GetROProperty to retrieve the current property value of objects in your application during the run session. For more information, see Retrieving and Setting Test Object Property Values.  

 

   Run-time Object

展现的是运行时本地测试对象的属性或方法。在脚本中可以通过Object属性来访问和获取Run-time Object的属性或执行其方法。

例如:

Dim MyDay   Set MyDay=Browser("index").Page("Untitled").ActiveX("MSCAL.Calendar.7").Object.Day  

 

    下面的脚本则通过Object属性执行测试对象的某个方法:

Dim MyWebEdit   Set MyWebEdit=Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Object  MyWebEdit.focus   

 

而对于Test Object则可通过GetTOProperty 和 SetTOProperty 来获取或设置测试对象的属性值。

 

例如: 

Browser("QA Home Page").Page("QA Home Page").WebButton("Submit").SetTOProperty "Name", "my button"  

ButtonName=Browser("QA Home Page").Page("QA Home Page").WebButton("Submit").GetTOProperty("Name")     

下面的脚本通过GetROProperty访问测试对象当前的属性值: 

link_href = Browser("Mercury Technologies").Page("Mercury Technologies").Link("Jobs").GetROProperty("href")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值