Micro Focus QTP (UFT) Forums
QTP 9.2 .Net - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: QTP 9.2 .Net (/Thread-QTP-9-2-Net)



QTP 9.2 .Net - sbonsteel - 06-06-2008

I am running QTP 9.2 with .net and ActiveX addins. The click in the code does not work consistently. When it errors, I get "object not found". Does anyone have any ideas on the problem?


Code:
Function fnClickKeyPadKey(strKeyName)

    Dim objswfWinDesc, objswfWinColl
    Dim objswfObjDesc, objswfObjColl
    strFound = False
    
    If Window(POS).Window(Keypad).Exist Then
        Set objswfWinDesc = Description.Create()
        objswfWinDesc("swftypename").Value = "FLIBCustomControlBridgeNet.ButtonWindow"

        Set objswfWinColl = Window(POS).Window(Keypad).ChildObjects(objswfWinDesc)
        For i = 0 to objswfWinColl.Count-1
            Set objswfObjDesc = Description.Create()
            objswfObjDesc("swftypename").Value = "FLIBCustomControlBridgeNet.ButtonControl"

            Set objswfObjColl = objswfWinColl(i).ChildObjects(objswfObjDesc)
            
            If objswfObjColl.Count = 1 Then
                strName = objswfObjColl(0).GetROProperty("text")
                strActualName = UCase(Replace(Replace(Replace(Trim(strName), VbCrLf, " "), VbTab, " "), " ", ""))
                strExpectedName = UCase(Replace(Replace(Replace(Trim(strKeyName), VbCrLf, " "), VbTab, " "), " ", ""))
            
                If  strActualName = strExpectedName  Then

                    objswfWinColl(i).Click 1, 1
            
                    strFound = True
                    Set objswfObjDesc = Nothing
                    Set objswfObjColl = Nothing
            
                    Exit For
              
                End If
                
            End If
            
            Set objswfObjDesc = Nothing
            Set objswfObjColl = Nothing
            
         Next

        If strFound Then
             fnClickKeyPadKey = True
        Else
            fnClickKeyPadKey = False
        End If
        
          Set objswfWinDesc = Nothing
          Set objswfWinColl = Nothing
   Else
        Print  "The Parent Object not found"            
    End If
    
End Function



RE: QTP 9.2 .Net - Amit Singh Chauhan - 06-12-2008

Hi,

Just replace Dim by Public in your code.
From:
Code:
Dim objswfWinDesc, objswfWinColl
    Dim objswfObjDesc, objswfObjColl

To:
Code:
Public objswfWinDesc, objswfWinColl
    Public objswfObjDesc, objswfObjColl

It worked for me when I was getting this kind of error for some other scenerio.


RE: QTP 9.2 .Net - sbonsteel - 06-12-2008

Thank you, I will give it a try.


RE: QTP 9.2 .Net - Amit Singh Chauhan - 06-12-2008

Hi

I am also trying to execute QTP test cases from .net

I have following scenerio
Machines A and B.
Machine A has Test Scripts and related libraries.
Machine B has only QTP installed.

I have created a .vbs file on Machine A which launches QTP on Machine B and run Test cases of Machine A.

I want to execute this .vbs file from VSTS.

Do you have any idea how to do this.