Micro Focus QTP (UFT) Forums

Full Version: Function to create web objects (like Browser, Link, Page, etc)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am trying to create a function that creates different web objects: Bowsers, Links, etc...
I am using DP.

Input to my function are the following three parameters:


1. The type of object (like "BROWSER")
2. One of the object's descriptive Properties (like "title")
3. The value of the Descriptive Property (like ("Home"))


Code:
Public Function createSingleObj(t, p, val)  
   Set o = Description.Create
       o("micclass").Value = t  
       o(p).Value =   val
       Set createBrwsrObj = o                
   End Function

However, the function hangs when reading the Descriptive Property value: o("title"). It just doesn't take the parameter I am passing in the function, p.

What can I do to feed a parameter instead of the actual property?


THANKS!!
Hi,
I could not find any issues in the script except that
Code:
Public Function createSingleObj(t, p, val)
Set o = Description.Create
o("micclass").Value = t
o(p).Value = val
Set createBrwsrObj= o
End Function
Set createBrwsrObj = o it should be Set createSingleObj = 0.
I assume you want to return to the calling function.

Also,
It would be better if you pass the property and values in an array so that you can pass n no of Prop Value pairs you want. You will not be limited to use just 1 Prop and value.

Code:
createSingleObj("Browser","CreationTime:=0,title:=AOL.*")

Public Function createSingleObj(t,arrPV)
        Set o = Description.Create
        o("micclass").Value = t
        arrPV = Split(arrPV,",")
        For iLoop = 0 to UBound(arrPV)
                Prop= Split(arrPV(iLoop),":=")(0)
                Val= Split(arrPV(iLoop),":=")(1)
                o(Prop).Value = Val
        Next
        Set createSingleObj = o
End Function


Thanks vIns...
And yes, I did have a typo...I need to sleep!!!
THANKS SO MUCH!