Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to convert a String into a Object
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi all,

I am trying to create a function to check if a user specified Object exists.

3 Input values is the Object Type, Object Name, and Object Id.

for eg: when we use the

Browser("micClass:=Browser").Page("micClass:=Page").Obj_type(Obj_id).Exists

[/quote][/code]
Code:
Function Obj_exists(Obj_type,Obj_name,Obj_id)
Set oPage = Browser("micClass:=Browser").Page("micClass:=Page")
//I tried the below code trying to use concatenation but it didnt work.
If   oPage.& Obj_type & ( & Obj_id & ) & . & Exist  Then

oPage.Obj_type(Obj_id).WaitProperty "Visible ","True "    
oPage.Obj_type(Obj_id).highlight
Reporter.ReportEvent micPass,"Object Verification","The Object of name "& Obj_name &"type" & Obj_type & " exists."
            else
Reporter.ReportEvent micFail,"Object Verification","The Object of name "& Obj_name &"type" & Obj_type & " does not exists."
End If
Set oPage = Nothing
End Function
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
try using Eval(). It will evaluate a string into an expression.

Regards,
Ankesh
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert the single to an integer Mozza 2 1,435 09-27-2018, 12:36 PM
Last Post: Ankur
  Need help in creating dynamic object string using Childobjects Keshub Mathur 0 1,629 09-11-2017, 05:52 PM
Last Post: Keshub Mathur
  How to have a variable that has a string comma string .. shareq1310 5 5,098 11-09-2011, 03:33 PM
Last Post: parminderdhiman84
  Version error - Convert QTP 9.5 scripts to QTP 9.2 shriqtp 6 5,890 09-02-2009, 11:03 PM
Last Post: Ankur
  string function to get a letter from a string ajay.r1982 3 7,670 06-30-2009, 08:58 PM
Last Post: Ankur

Forum Jump:


Users browsing this thread: 1 Guest(s)