使用QuickTest Pro获取Quality Center API接口ISupportCopyPaste的参考

时间:2011-01-21 07:18:30

标签: python api vbscript qtp hp-quality-center

Quality Center OTA API提供ISupportCopyPaste等接口(使用剪贴板复制/粘贴数据)。获得对已实现接口的引用的文档化方法是:

'Declare a variable to hold the reference for the interface 
Dim bf As IBaseFactory2 
' By assigning the implementing object reference to the 
' IBaseFactory2 type variable, the type is cast to that of the 
' implemented interface. The new variable is a reference to the 
' IBaseFactory2 interface within the parent object. 
' tdc is the global TDConnection object. 
Set bf = tdc.BugFactory

以上代码在VB中(我不想使用) 但是,QTP在Dim声明中不允许“As” 谁能说出如何使用QTP获取参考? 这个问题的任何其他解决方案?例如:使用Python Win32

2 个答案:

答案 0 :(得分:2)

QTP “不允许As语句中的Dim 的原因是QTP脚本基于VBScript 而不是 VB,并且As仅限VB(VBScript是动态类型的)。

如果要在QTP中使用OTA,可以尝试使用QTP公开的QCUtil对象(有关详细信息,请参阅QTP的帮助)。

如果QCUtil没有为您提供所需的对象,您可以使用任何知道如何与COM交互的语言来创建OTA对象(这些语言包括但不限于VB,VBScript ,C ++和.NET语言,我不确定Python)。

如果您确实选择使用VBScript,则可以使用VBScript的CreateObject函数创建OTA对象(搜索CreateObject OTA以获取更多信息)。

答案 1 :(得分:0)

理论上,大多数OTA公开的对象及其公开的接口都是IDispatch。

换句话说;从vbscript处理这些对象时,您不必将手头的对象强制转换为ISupportCopyPaste。您只需调用手头对象上的方法,就像它是ISupportCopyPaste一样,您只需要正确获取方法签名。

相关问题