Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a function for an object that has a large number of parent objects
#1
Not Solved
Hi.
I want a function that will use method on an object depending on the function parameters. For example:
Code:
Public Function fnJavaButton (objWindowDesc, objDialogDesc, objButtonDesc, strAction)
    Select Case strAction
        Case "Click"
JavaWindow("objWindowDesc").JavaDialog("objDialogDesc").JavaButton(objButtonDesc).Click
    End Select
End Function

The problem is that the number of parent objects can vary from one to seven. Should I add five more object parameters and an int parameter, that indicates how many parent objects is before the button? Is there any way to make that kind of function without adding a large number of parameters?
Reply
#2
Not Solved
Hi, try this:
Code:
PUBLIC FUNCTION CreateObjDes(ObjectFatherUFT,StrObjectClass,StrObjectProperty,StrObjectPropertyValue)
            'Example return one object:
            'CreateObjDes (Window("text:=Calculator"),"WinButton","text","9")).Click
            
            'Example for return a array objects
            'Set ObjButton= CreateObjDes (Window("text:=Calculator"),"WinButton","","")
            'ObjButton(0).Click
            Set ObjDesObject=Description.Create()
                ObjDesObject("micClass").value= StrObjectClass

            Set ObjDesObjectChild=ObjectFatherUFT.ChildObjects(ObjDesObject)

            Dim IntCiclo
                IntCiclo=0

            If strcomp(StrObjectProperty,"") <> 0 Then

                For IntCiclo=0 to ObjDesObjectChild.count -1
                    If strcomp(StrObjectPropertyValue, trim(ObjDesObjectChild(IntCiclo).GetROProperty(StrObjectProperty)))=0 Then
                    SET CreateObjDes= ObjDesObjectChild(IntCiclo)

                    End If
                Next            
            Else
                SET CreateObjDes= ObjDesObjectChild
                
            End If
        END FUNCTION
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Passing Object to Function Mozza 2 1,927 08-02-2018, 03:22 AM
Last Post: Mozza
  does WebTable Object provides a method to get column number umer830 4 13,046 07-06-2018, 09:32 AM
Last Post: vijaychourasiya0109@gmail.com
Question Is there a way to create dynamic objects by declaring the type of object as parameter lotos 3 2,236 11-08-2017, 11:15 PM
Last Post: lotos
  Problem with large webtable JoshS 0 1,824 08-26-2015, 04:04 AM
Last Post: JoshS
  QTP is not identifying Parent objects it self then how can we automate swapna.9n9 0 2,043 12-11-2014, 04:32 PM
Last Post: swapna.9n9

Forum Jump:


Users browsing this thread: 1 Guest(s)