使用 QuickTest Pro 获取 Quality Center API 接口 ISupportCopyPaste 的参考
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
Quality Center OTA API provides interfaces like ISupportCopyPaste (copy/paste data using clipboard). The documented way to get a reference to an implemented interface is:
'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
The above code is in VB (which I don't want to use).
However, QTP does not allow 'As' in Dim statement.
Can anyone tell how to get a reference using QTP ?
Any other solution to this problem ? eg: using Python Win32
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
QTP“不允许在
Dim
语句中使用As
”的原因是 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 了解更多信息)。The reason QTP "doesn't allow
As
inDim
statement" is that QTP scripts are based on VBScript not VB, andAs
is VB only (VBScript is dynamically typed).If you want to use OTA in QTP you can try using the
QCUtil
object that QTP exposes (see QTP's help for more information).If
QCUtil
doesn't give you the objects you need you can use any language that knows how to interact with COM in order to create the OTA object (these languages include but are not limited to, VB, VBScript, C++ and .NET languages, I'm not sure about Python).If you do choose to use VBScript you can create the OTA object using VBScript's
CreateObject
function (search for CreateObject OTA for more information).理论上,大多数 OTA 暴露的对象及其暴露的接口都是 IDispatch。
换句话说;当从 vbscript 处理这些对象时,您实际上不必将手头的对象转换为 ISupportCopyPaste。您可以像调用 ISupportCopyPaste 一样调用当前对象上的方法,只需获得正确的方法签名即可。
In theory most of OTA exposed objects and the interfaces they expose are IDispatch.
In other words; when working with these objects from vbscript, you don't really have to cast the object at hand to ISupportCopyPaste. You can just invoke the methods on the object at hand as if it was ISupportCopyPaste, you just need to get the method signature right.