51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2278|回复: 4
打印 上一主题 下一主题

[原创] SetAssociatedAddins的参数!

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2008-7-29 15:59:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我在VB.NET中调用QTP对象的SetAssociatedAddins方法时,总是返回“参数不正确”的异常,不知道有人是否碰到过,如何解决?谢谢!下面是相关的代码:

'将所有的addins与当前test相关联
Dim arr1() As String = {"ActiveX", "Visual Basic", "Web"}
Dim  appQTP as New QuickTest.Application
appQTP.Launch()
appQTP.Visible = True
appQTP.Open("D:\test1")

'获取与当前test相关联的addins, 假设有部分addins还没有被关联
arrTestAddins = appQTP.Test.GetAssociatedAddins()

Dim  blnActivateOK

'我尝试使用以下两种方式来设置,但全部返回参数错误的异常
1. blnActivateOK = appQTP.Test.SetAssociatedAddins(arr1) '直接使用字符串数组
2 .blnActivateOK = appQTP.Test.SetAssociatedAddins(appQTP.Addins)'直接使用addins集合对象

If Not blnActivateOK Then ' If a problem occurs while loading the add-ins
    MsgBox("Failed to add addins") ' Show a message containing the error
End If

appQTP.Quit()
appQTP = Nothing

[ 本帖最后由 bsbolg 于 2008-7-29 17:34 编辑 ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2008-7-29 17:23:28 | 只看该作者
这是帮助里面的例子:
'************************************************************************************************************************
'Description:
'
'This example replaces the Java Add-in with the Oracle Add-in in the
'associated add-ins list of the specified 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
Directory = InputBox("Enter the path of the test you want to convert.")
Call ConvertTest(Directory)
Private Function ConvertTest(TestPath)
    ' Create the Application object
    Set qtApp = CreateObject("QuickTest.Application")
    ' Open the test.
    Call qtApp.Open(TestPath)
    ' Retrieve the list of the test's associated add-ins
    Addins = qtApp.Test.GetAssociatedAddins()
    ' If Java appears in the retrieved list, replace it with Oracle.
    For i = 0 To UBound(Addins)
        If Addins(i) = "Java" Then
            Addins(i) = "Oracle"
        End If
    Next
    ' Apply the new associated add-ins list to the test.
    If Not qtApp.Test.SetAssociatedAddins(Addins, ErrorDesc) Then
                MsgBox "Unable to modify the associated add-ins for this test: " _
                    & Chr(13) & TestPath _
                    & Chr(13) & ErrorDesc
                Exit Function
            End If
    ' If the change is successful, save the test.
    Call qtApp.Test.Save
End Function
SetAssociatedAddins方法的参数应该是数组
回复 支持 反对

使用道具 举报

该用户从未签到

3#
 楼主| 发表于 2008-7-29 17:38:03 | 只看该作者
尝试过你代码,但依然报参数不正确的异常!谢谢!传入字符串数组,或者addins数组都不行。如果我使用VBSCRIPT可以通过,但VB.NET里面就报错。郁闷,帮助里面的相关例子都试过,没有成功的。不知原因何在

[ 本帖最后由 bsbolg 于 2008-7-29 17:39 编辑 ]
回复 支持 反对

使用道具 举报

该用户从未签到

4#
发表于 2008-7-29 17:58:00 | 只看该作者
帮助里的例子都是基于VBS的,你干吗要在VB.NET里跑?
回复 支持 反对

使用道具 举报

该用户从未签到

5#
 楼主| 发表于 2008-7-29 18:05:42 | 只看该作者
在用QTP的API做个工具,没办法。其他对象的方法都可以用,只有这个不好使!
回复 支持 反对

使用道具 举报

本版积分规则

关闭

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

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

GMT+8, 2024-9-22 01:20 , Processed in 0.078940 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

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