06-06-2008, 12:15 AM
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