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

《QTP自动化测试最佳实践》 同时被 3 个专栏收录
10 篇文章 0 订阅
271 篇文章 0 订阅
213 篇文章 1 订阅

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
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值