Micro Focus QTP (UFT) Forums
Count and get the properties of different objects in a Java form - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Count and get the properties of different objects in a Java form (/Thread-Count-and-get-the-properties-of-different-objects-in-a-Java-form)



Count and get the properties of different objects in a Java form - riechan - 07-16-2012

Hi guys,

Can anyone help me with what I'm trying to do here? I'm trying to get the properties (developer name, attached text) of several objects (edit boxes, tables, buttons, etc.) from a Java application. Here's the code I'm using:

Code:
Function CreateObjectConfig(objWindow, strTblName, strObjectClass, strPage)

    Set getElement = Description.Create()
        getElement("Class Name").Value = strObjectClass
        getElement("micclass").Value = strObjectClass

    If strObjectClass = "JavaEdit" Then
        getElement("class description").value = "edit"
        getElement("toolkit class").value = "model.UIMaskedTextField"
    End If

    MsgBox objWindow.ChildObjects(getElement).count
    Set newObject = objWindow.ChildObjects(getElement)

    strFieldName = ""

    For ctrElement = 0 to getElement.Count - 1
        strDeveloperName = getElement(ctrElement).GetROProperty("developer name")

        If InStr(1, UCase(strObjectClass), "BUTTON") > 0 Then
            strAttachedText = newObject(ctrElement).GetROProperty("attached text")
        ElseIf InStr(1, UCase(strObjectClass), "EDIT") > 0 Then
            strAttachedText = newObject(ctrElement).GetROProperty("attached text")
        ElseIf InStr(1, UCase(strObjectClass), "EDIT") > 0 Then
            strAttachedText = newObject(ctrElement).GetROProperty("attached text")
        End If

        If Len(strAttachedText) = 0 or strAttachedText = "|" Then
            strAttachedText = "***"
        End If
    Next
...
End Function

The thing is, the objWindow.ChildObjects(getElement).Count always returns 0, even though I can access the objects in the form with descriptive programming (using the attached text and developer name as identifiers). Can anyone help me with the object description? I'm guessing that there's something wrong with how I described the objects that's why the ChildObjects() is returning a zero.

Also, what's the huge difference between using the micclass from Class Name? Oftentimes, micclass doesn't work when I'm using it for object descriptions, and Class Name just fits the bill...