QTP对象库管理 - 动态绑定对象库文件

QTP对象库管理 - 动态绑定对象库文件:

TestOR.vbs:

'************************************************************************************************************************
'Description:
'
'This example opens a test, configures an action's object repositories collection
'and saves the test.
'
'Assumptions:
'There is no unsaved test currently open in QuickTest.
'For more information, see the example for the Test.SaveAs method.
'************************************************************************************************************************

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtRepositories 'As QuickTest.ObjectRepositories ' Declare an action's object repositories collection variable
Dim lngPosition

' Open QuickTest
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Launch QuickTest
qtApp.Visible = True ' Set QuickTest to be visible

' Open a test and get the "Login" action's object repositories collection
qtApp.Open "C:\Documents and Settings\allen\桌面\TestOR", False, False ' Open a test
Set qtRepositories = qtApp.Test.Actions("Action2").ObjectRepositories ' Get the object repositories collection object of the "Action2" action

' Add NewOR.tsr if it's not already in the collection
If qtRepositories.Find("C:\Documents and Settings\allen\桌面\TestOR\OR\NewOR.tsr") = -1 Then ' If the repository cannot be found in the collection
    qtRepositories.Add "C:\Documents and Settings\allen\桌面\TestOR\OR\NewOR.tsr", 1 ' Add the repository to the collection
End If

' If Debug.tsr is in the collection - remove it
lngPosition = qtRepositories.Find("C:\Debug.tsr") ' Try finding the Debug.tsr object repository
If lngPosition <> -1 Then ' If the object repository was found in the collection
    qtRepositories.Remove lngPosition ' Remove it
End If

' Set the new object repository configuration as the default for all new actions
qtRepositories.SetAsDefault ' Set object repositories associated with the "Action2" action as the default for all new actions

Set qtTest = qtApp.Test
qtTest.Run

'Save the test and close QuickTest
qtApp.Test.Save ' Save the test
qtApp.Quit ' Quit QuickTest

Set qtRepositories = Nothing ' Release the action's shared repositories collection
Set qtApp = Nothing ' Release the Application object

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值