|
参考下面的代码可以解决你的问题
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 "E:\QTPBASE\CodeSamplesPlus\Flight_Samples\LoginBoundry", False, False ' Open a test
Set qtRepositories = qtApp.Test.Actions("LoginErrors").ObjectRepositories ' Get the object repositories collection object of the "Login" action
' Add MainApp.tsr if it's not already in the collection
If qtRepositories.Find("E:\QTPBASE\CodeSamplesPlus\Flight_Samples\SOR.tsr") = -1 Then ' If the repository cannot be found in the collection
qtRepositories.Add "E:\QTPBASE\CodeSamplesPlus\Flight_Samples\SOR.tsr", 1 ' Add the repository to the collection
End If
' Set the new object repository configuration as the default for all new actions
qtRepositories.SetAsDefault ' Set object repositories associated with the "Login" action as the default for all new actions
qtRepositories.RemoveAll() |
|