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 vari开发者_开发技巧able, 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 Win32The 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).
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.
精彩评论