Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function to create web objects (like Browser, Link, Page, etc)
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
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!!
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
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


Reply
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
Thanks vIns...
And yes, I did have a typo...I need to sleep!!!
THANKS SO MUCH!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can QTP handle slick grid table in a web page qtplearner88 2 4,564 10-01-2019, 10:44 AM
Last Post: shilpi952
  Child Object Not able to identified in Web Menu Link noor 0 1,882 01-21-2018, 04:44 PM
Last Post: noor
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
  DP Web Browser/Page issues rstimers 1 2,493 08-14-2015, 12:37 PM
Last Post: venkatesh9032
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 3,033 11-27-2014, 12:53 PM
Last Post: jitenderkkr

Forum Jump:


Users browsing this thread: 1 Guest(s)