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

发布于 2024-10-13 03:56:15 字数 626 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一萌ing 2024-10-20 03:56:15

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 in Dim statement" is that QTP scripts are based on VBScript not VB, and As 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).

温馨耳语 2024-10-20 03:56:15

理论上,大多数 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文