51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 3126|回复: 6
打印 上一主题 下一主题

[求助] 如何通过脚本关联Object Repository

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2007-12-13 11:04:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
除了通过Resource ---> Object Repository 来关联某个对象库, 是否可以通过代码进行关联? 比如类似于data table的import方法:

DataTable.import("d:\qtp\data\dataTable.xls")
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2007-12-13 11:50:18 | 只看该作者
能问一下你为什要这么做呢,你的需求是什么?
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2007-12-13 12:21:11 | 只看该作者
在qtp的 automation object  model中可以设置object repository
下面为代码
'************************************************************************************************************************

'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:\Tests\Test1", False, False ' Open a test

Set qtRepositories = qtApp.Test.Actions("Login").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("C:\MainApp.tsr") = -1 Then ' If the repository cannot be found in the collection

    qtRepositories.Add "C:\MainApp.tsr", 1 ' Add the repository to the collection

End If



' If InnerWnd.tsr is moved down the list - place it back at position 1

If qtRepositories.Count > 1 And qtRepositories.Item(2) = "C:\InnerWnd.tsr" Then ' If there's more than one object repository and InnerWnd.tsr is in position 2

    qtRepositories.MoveToPos 1, 2 ' Switch between the first two object repositories

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 "Login" action as the default for all new actions



'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

具体的可以查看安装目录下的help的 QuickTest Automation Reference帮助文件,我用的是9.0版本,不知道其它的版本有没有区别.这是曲线的一种方法,

[ 本帖最后由 zhou840401 于 2007-12-13 12:24 编辑 ]
回复 支持 反对

使用道具 举报

该用户从未签到

4#
 楼主| 发表于 2007-12-13 18:22:25 | 只看该作者
我们在做自动化脚本自动生成工具, 现在可以支持的平台包括RFT, QTP, 这个自动化工具可以自动生成为目标测试平台所支持的object repository, test script, test data, 最后希望将产生的script与object repository自动关联起来, 而不是在qtp环境中打开test script之后, 通过在环境中设置这些关联, 不知道我有没有回答你的问题?

[ 本帖最后由 linxiaow 于 2007-12-13 18:30 编辑 ]
回复 支持 反对

使用道具 举报

该用户从未签到

5#
 楼主| 发表于 2007-12-13 18:28:24 | 只看该作者

谢谢 zhou840401

谢谢这位仁兄, 你的这个方法我试过了, 但是vbs文件执行出错, 初步预计是qtp安装的时候没有成功的注册某个com组建导致的, 但现在看来, 这是唯一可以满足我们需求的方法.
回复 支持 反对

使用道具 举报

该用户从未签到

6#
发表于 2007-12-14 13:07:53 | 只看该作者
用第三方的东西来执行qtp的脚本,也是一种好方法.不过就需要自已再编写脚本了.
回复 支持 反对

使用道具 举报

该用户从未签到

7#
发表于 2008-1-31 17:47:48 | 只看该作者
为什么我 执行到 Set qtRepositories = qtApp.Test.Actions("Login").ObjectRepositories 这句话的时候 报错 说 对象不支持此属性或方法 “Test.Actions”why???????????????????
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-10-5 20:22 , Processed in 0.091668 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表