Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code to Identify type of object
#1
Solved: 10 Years, 9 Months, 2 Weeks ago
Is there any function that returns the type of object.
For example edit box on a windows application falls under "WinEdit" Class.
So can some one help me with a function/method which returns the class of the object
Reply
#2
Solved: 10 Years, 9 Months, 2 Weeks ago
Hi Prasad,

msgbox ObjectType(Window("").winEdit(""))
Code:
Public ObjectType(strobjPath)
  If strobjPath.Exist Then
    strobjType = strobjPath.GetTOProperty("Class Name")
    ObjectType = strobjType
  Else
   ObjectType = strobjPath & "object does not exist."
  EndIF
End Function
Please let me know if you need any more info.
Thanks,
SUpputuri
Reply
#3
Solved: 10 Years, 9 Months, 2 Weeks ago
Hi Supputuri,

Thanks for your response. The above code returns WinEdit when I pass Dialog("Login").WinEdit("Agent Name:") as parameter to ObjectType Function.

My requirement is, I will pass the Window Name i.e "Login" and object name i.e "AgentName: " Is there any way to get what class of objects they are. Dialog for "Login" and WinEdit for "Agent Name: "

Thanks,
Prasad
Reply
#4
Solved: 10 Years, 9 Months, 2 Weeks ago
Hi Prasad,

You can try the following piece of code. But before trying make sure that all the properties are present that are being used over here. Or you can change it according to your application

Code:
Function returnObjClass(ByVal windName,ByVal objName)
      Set obj = Description.Create
      obj("name").Value = objName //make sure "name" property is present for the object
      Set allObj = Window("regexpwndtitle:="&windName).ChildObjects(obj)
      If allObj.Count > 1 Then
      msgbox "More than one Object found having this property"
      End If
      returnObjClass = allObj(0).GetROProperty("Class Name")
End Function

Then from QTP call the function as follows:

Code:
getClassName = returnObjClass("Your Window Name","Your Object Name")
msgbox getClassName

Hope it will serve to your need.
Reply
#5
Solved: 10 Years, 9 Months, 2 Weeks ago
Thank You Very Much Prabhat. I tried your function and it solved my problem Smile. I used "attached text" instead of "name" for the below line
obj("name").Value = objName
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Different Type of Dropdown Selector zunebuggy 6 2,863 05-01-2018, 06:46 PM
Last Post: zunebuggy
  Cannot identify the object "Webtable" korunu 1 2,398 06-29-2016, 05:28 PM
Last Post: Ankesh
  Cannot identify the object "Webtable" korunu 0 1,666 05-11-2016, 12:02 AM
Last Post: korunu
  QTP "Cannot identify the object" richardpaulhall_2 3 13,335 08-20-2015, 11:46 PM
Last Post: ADITI1992
  cannot use the type method on object and submit is not working jove1776 5 8,385 01-27-2015, 10:08 PM
Last Post: Parke

Forum Jump:


Users browsing this thread: 1 Guest(s)