Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to capture text from a tooltip using QTP
#1
Not Solved
I had gone through this site and still since unable to capture the tool tip as my AUT is a Java Application and have embedded Java Applet and Swing features. And tool tip of it could not be captured as simple as like that. So I have followed bitmap file comparison.
This is only for reference, NOT a question to other. Smile

Ex:
Code:
Set objParent = JavaWindow("XXX")
objTest = fngetWithParentJavaApplet(objParent,"JavaObject","tagname","SchemaViewComponent")
objTest1 = fnGetOthrChldObjOfJavaApplet(objTest(0),"JavaObject","tagname","JToolTip")
If Not IsEmpty(objTest1(0)) Then
    objTest1(0).CaptureBitmap "C:\TempToolTip.bmp",True
    wait 2
    If comparebitmap("C:\TempToolTip.bmp","<expected bitmap file>") Then
        Reporter.ReportEvent micPass,"Comparing Tooltip bitmap", "Actual Tool tip bmp matches with expected bmp"
        Else
        Reporter.ReportEvent micFail,"Comparing Tooltip bitmap", "Actual Tool tip bmp does NOT match with expected bmp"
    End If
    Else
    Reporter.ReportEvent micFail,"Capturing Tooltip","Failed to open tooltip for  SIDCommon domain schema"
End If

function comparebitmap(actualbmp, expectedbmp)
    set fcomapre = createobject( "mercury.filecompare" )
    if fcomapre.isequalbin(actualbmp, expectedbmp, 0, 1) Then
    
    comparebitmap = true
    
    else
    comparebitmap =  false
    
    end if
End Function

'Gets the Child the child object whose property has been passed as parameter and the
'associated parent Applet
Public Function fngetWithParentJavaApplet(pObjParJavaWin,pStrChldObj,pStrProp,pStrVal)
   Dim Desc,Lists,i
   Dim Desc1,Lists1,j
   Dim obja(1)
   Dim arrProp
   Dim arrPropVal
   Dim boolMatchProp,k

    arrProp = Split(pStrProp,";")
    arrPropVal = Split(pStrVal,";")

    Set Desc = Description.Create()
    Desc("Class Name").Value = "JavaApplet"
    Set Lists =pObjParJavaWin.ChildObjects(Desc)
    wait 2
    For i = 0 To Lists.Count - 1
        Set Desc1 = Description.Create()
        Desc1("Class Name").Value = pStrChldObj
        Set Lists1 =Lists(i).ChildObjects(Desc1)
        wait 2
        If Lists1.Count <>0 Then
            For j = 0 to Lists1.Count -1
                boolMatchProp = False
                For k = 0 to Ubound(arrProp)
                   If Lists1(j).getROProperty(arrProp(k)) = arrPropVal(k) Then
                       If k = 0 Then
                           boolMatchProp = True
                           Else
                           boolMatchProp = True and boolMatchProp
                       End If
                       Else
                       boolMatchProp = False
                   End If
               Next
                If boolMatchProp = True Then
'                If Lists1(j).getROProperty(pStrProp) =pStrVal Then
                    Set obja(0) = Lists(i)
                    Set obja(1) = Lists1(j)
                    fngetWithParentJavaApplet = obja
                    wait 2
                    Exit Function
                End If
            Next
        End If
    Next
    
    fngetWithParentJavaApplet = obja
    
End Function 'fngetWithParentJavaApplet

'To get other child object of the parent JavaApplet
Function fnGetOthrChldObjOfJavaApplet(pObjParJApplet,pStrChldObj,pStrProp,pStrVal)
   Dim Desc,Lists,i
   Dim obja(1)
   Dim arrProp
   Dim arrPropVal
   Dim boolMatchProp,j

    arrProp = Split(pStrProp,";")
    arrPropVal = Split(pStrVal,";")


        Set Desc = Description.Create()
        Desc("Class Name").Value = pStrChldObj
        Set Lists =pObjParJApplet.ChildObjects(Desc)
        wait 2
        If Lists.Count <>0 Then
            For i = 0 to Lists.Count -1
                boolMatchProp = False
                For j = 0 to Ubound(arrProp)
                   If Lists(i).getROProperty(arrProp(j)) = arrPropVal(j) Then
                       If j = 0 Then
                           boolMatchProp = True
                           Else
                           boolMatchProp = True and boolMatchProp
                       End If
                       Else
                       boolMatchProp = False
                   End If
               Next
                If boolMatchProp = True Then
                    Set obja(0) =  Lists(i)
                    fnGetOthrChldObjOfJavaApplet = obja
                    wait 2
                    Exit Function
                End If
            Next
        End If
    fnGetOthrChldObjOfJavaApplet = obja

End Function 'fnGetOthrChldObjOfJavaApplet
Reply
#2
Not Solved
This code retrieve the text from a tool tip that appears when you move mouse over a cell of a JavaTable. The code parse the table line by line and retrieve the tool tip value that appears on every line

Code:
Set objJavaTable=JavaWindow("CM Uebersicht").JavaTable("Javatable").Object
set  Rect=objJavaTable.getCellRect(counter,0,True)
RectString=Rect.ToString()


intermediar1=split(RectString,"=",3,1)
intermediar2=split(intermediar1(1),",",2,1)
intermediar3=split(intermediar1(2),",",2,1)
x=Cint(intermediar2(0)) +10
y=Cint(intermediar3(0))

JavaWindow("CM Uebersicht").JavaTable("Javatable").FireEvent micMouseMove ,50, 0,x, y, 1, "OFF"

test2=JavaWindow("CM Uebersicht").JavaObject("JToolTip").Exist(1)
set objToolTip=JavaWindow("CM Uebersicht").JavaObject("JToolTip").Object

DocumentStatus=objToolTip.getTipText()
Reply
#3
Not Solved
In case someone is interested, we have discussed here 4 ways to capture tool tip using UFT
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using QTP to capture screen shot ravi.gajul 12 77,029 08-10-2017, 06:58 AM
Last Post: pauljo.kld@gmail.com
  capture screenshot using html code and view in QTP Test results Bhuvan 3 7,211 07-19-2013, 02:38 PM
Last Post: Bhuvan
Question Capture hidden automatic number from database via QTP rani26 1 3,391 08-18-2008, 06:34 PM
Last Post: srinivas

Forum Jump:


Users browsing this thread: 1 Guest(s)