|
我要网上找到了以下的代码,但是却总是不成功。
以下是 Example script:
' 載入 Object Repository
Set oru = CreateObject ("Mercury.ObjectRepositoryUtil")
oru.LoadActionRepository "C:\Temp\Login","Action1"
' 取得 Parent Object
Set ParentObj = oru.GetObjectByParent( NULL, "Dialog(""Login"")" )
' 創建新的 Test Object ( A Stdbutton in this case ) 並設置其屬性
set StdButton = CreateObject("Mercury.WinButton")
StdButton.SetTOProperty "text","Cancel"
StdButton.SetTOProperty "nativeclass","Button"
' 將新的 Test Object (StdButton) 加到 parent object
' ( DialogBox). Set the logical name of the new Test Object to "Cancel"
oru.AddObject StdButton, ParentObj, "Cancel"
' 儲存 Object Repository
oru.Save
Set ParentObj = nothing
Set StdButton = nothing
Set oru = nothing
它总是要那它红色的代那里出错。提示为:'GetObjectByParent' - Object cannot be found.。
我用的是QTP 8.2
[ 本帖最后由 hcgzzz 于 2007-8-6 17:51 编辑 ] |
|