Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MicWpfWindow from .NET AOM
#1
Not Solved
Dear all,

I'm trying to load a basic object repository into .NET Visual Basic
code. Mercury.ObjectRepositoryUtil is not available for some reason
(I have QTP 10.00). There is, however
REPOSITORYUTILLIb.ObjectRepositoryUtil, so I tried to use that.

I need to do things like

Code:
Window("windowName").Activate
from within .NET VisualBasic.

Apparently, MicWpfWindow class has all the right methods. This may or may
not be the thing to look for, I don't know.

But obtaining a reference to a MicWpfWindow from the object repository is
a bit problematic. It appears that the repository util contains a bunch of
__ComObject's.
But none of them casts to a MicWpfWindow or a WpfWindow interface.

Could somebody advise me, please? Thanks!

PS.

I have imported
QTAutomationAgent.exe
REPOSITORYUTILLIb.dll
Mercury.WpfPackage.Interop.dll
WpfPackage.dll
QTApplicationObj.dll
QTApplicationObjLib.dll


I have tried the following:

Code:
Dim orep As REPOSITORYUTILLib.ObjectRepositoryUtilClass
        orep = New ObjectRepositoryUtil()
        Dim orepType As Type = orep.GetType
        orep.Load(repoPath)


        '' Just a simple call to GetAllObjects doesn't work
        Dim children As Object = _
             orepType.InvokeMember("GetAllObjects", Reflection.BindingFlags.InvokeMethod, _
                                    Nothing, orep, New Object() {Nothing})

        Dim childrenType As Type = children.GetType
        Dim cnt As Integer

        '' Retrieve count ''''''''''''''''''''''''''''''''''''''''''''
        cnt = CInt(childrenType.InvokeMember("Count", _
                    Reflection.BindingFlags.InvokeMethod, Nothing, children, Nothing))



        For i As Integer = 0 To cnt - 1
            ' obj.GetType is telling me that this is a __ComObject
            Dim obj As Object = childrenType.InvokeMember("Item", Reflection.BindingFlags.InvokeMethod, _
                                                          Nothing, children, New String() {i.ToString})
            Dim logName As String = orep.GetLogicalName(obj)

            If logName = "Notepad" Then
                '' Unable to cast COM object Exception
                Dim win As Mercury.WpfPackage.Interop.WpfWindow = obj
            End If
        Next i


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  AOM script is running only one or two scripts. jramya 4 4,196 07-24-2014, 06:15 PM
Last Post: jramya
  How to invoke the recording of QTP using AOM(automation object model) of QTP shailesh.gcettb@gmail.com 2 4,184 05-08-2014, 10:30 AM
Last Post: Shriram
  Can QTP AOM identify word documents that are already opened anil2u 2 4,435 09-05-2013, 12:45 PM
Last Post: anil2u
  AOM in QTP sowmya R 1 2,383 07-27-2012, 05:01 PM
Last Post: ssvali
  What is the use of AOM ? kirangoud 5 4,433 03-16-2012, 11:20 AM
Last Post: sshukla12

Forum Jump:


Users browsing this thread: 1 Guest(s)