Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用QuickTest Pro获取对质量中心API接口ISupportCopyPaste的引用_Python_Api_Vbscript_Qtp_Hp Quality Center - Fatal编程技术网

Python 使用QuickTest Pro获取对质量中心API接口ISupportCopyPaste的引用

Python 使用QuickTest Pro获取对质量中心API接口ISupportCopyPaste的引用,python,api,vbscript,qtp,hp-quality-center,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 variab

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 Win32QTP“不允许
Dim
语句中的
As
”的原因是QTP脚本基于VBScript而不是VB,并且
As
仅是VB(VBScript是动态键入的)

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

<> > <代码> QCUTIL> /COD>不给您所需的对象,您可以使用任何知道如何与COM进行交互的语言来创建OTA对象(这些语言包括但不限于VB、VBScript、C++和.NET语言,我不确定Python)。p>
如果选择使用VBScript,则可以使用VBScript的功能(搜索更多信息)创建OTA对象。

理论上,大多数OTA暴露对象及其暴露的接口都是IDispatch


换言之;从vbscript处理这些对象时,实际上不必将手头的对象强制转换为ISupportCopyPaste。您可以像调用ISupportCopyPaste一样调用手头对象上的方法,只需正确获取方法签名。

感谢您提供更好的解释。我已经能够在VBScript和Python中完成您提到的所有操作。但我想在QC中将测试集从一个文件夹“复制”到另一个文件夹。我在OTA引用中找不到任何要复制的方法(尽管有一个Move方法)。一种方法是实现ISupportCopyPaste接口。所以,我的问题是如何做到这一点?@manas,如果您安装了MS Excel,您可以使用VBA,它确实支持通过Dim语句中的那样进行强制转换。事实上,我使用Excel的VBA成功地实现了QC和QTP API的自动化。我尝试了有文档记录的方法签名,但没有成功。你能给我介绍一下实现接口的例子吗?任何规则都有例外,ISupportCopyPaste就是例外。ISupportCopyPaste是IUnknown而不是IDispatch。我看到的唯一选项是检查QCUtils是否提供了您需要的功能。或者您可以编写自己的COM助手类(比如在.net中),它允许IUnknown和QueryInterface调用。我从你的剧本中找到了那门课。