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

来源:互联网 发布:奥斯卡级核潜艇知乎 编辑:程序博客网 时间:2024/05/17 08:43

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

0 0