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

发表于:2008-05-28来源:作者:点击数: 标签:qtpQTPObjectobject属性
用object spy查看 测试 对象时,有runtime object properties 和 test object properties两种,那么它们有什么区别呢? 从QTP的帮助文档可以看出Run-time Object Properties与Test Object Properties之间的区别: (1)Run-time Object Properties / Run-time O
用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  

Displaysthe run-time (native) object properties or methods associated with theobject selected in the Object Spy's object hierarchy tree. Note thatthe label changes depending on whether the Properties or Methods tab isselected. You can use the Object property to retrieve or activaterun-time properties and methods displayed in the Object Spy. For moreinformation, see Retrieving Run-Time Object Properties and ActivatingRun-Time Object Methods.

(2)Test Object Properties / Test Object Methods  

Displaysthe test object properties or methods associated with the objectselected in the Object Spy's object hierarchy tree. Note that the labelchanges depending on whether the Properties or Methods tab is selected.You can use the GetTOProperty and SetTOProperty methods to retrieve andset the value of test object properties for test objects in your test.You can use the GetROProperty to retrieve the current property value ofobjects in your application during the run session. For moreinformation, 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")

原文转自:http://www.ltesting.net