從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展現的是運行時(shí)本地測試對象的屬性或方法。在腳本中可以通過(guò)Object屬性來(lái)訪(fǎng)問(wèn)和獲取Run-time Object的屬性或執行其方法。例如:
Dim MyDay Set MyDay=Browser("index").Page("Untitled").ActiveX("MSCAL.Calendar.7").Object.Day
下面的腳本則通過(guò)Object屬性執行測試對象的某個(gè)方法:
Dim MyWebEdit Set MyWebEdit=Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Object MyWebEdit.focus
而對于Test Object則可通過(guò)GetTOProperty 和 SetTOProperty 來(lái)獲取或設置測試對象的屬性值。例如:
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")
下面的腳本通過(guò)GetROProperty訪(fǎng)問(wèn)測試對象當前的屬性值:
link_href = Browser("Mercury Technologies").Page("Mercury Technologies").Link("Jobs").GetROProperty("href")
延伸閱讀
文章來(lái)源于領(lǐng)測軟件測試網(wǎng) http://kjueaiud.com/