UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21. Read more.
UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21.Read more.
Absent Member.
Absent Member.
280 views

Need a program in QTP to identify all the enterable fields in a page

I need to develop a program in QTP which will recognize all the enterable fields in a page like textboxes, checkboxes, radioboxes, drop down lists(all the user selectable/enterable fields). I need to identify the objects and capture the label beside the objects and write it in an excel. Is this possible to do with QTP? Please help me
0 Likes
9 Replies
Absent Member.
Absent Member.

Is this for a web application?

If that is the case this might be very difficult to impossible. In a lot of cases the label for a textbox, select box can be independent of the object (even more so with CSS). The best you can do is to get the object names and hope the developers used something logical.
0 Likes
Absent Member.
Absent Member.

Actually Iam trying it for web application. Any web page. But the actual need is for a new product. In that product the enterable fields have an attribute label which will be same as the label for those fields. Now the problem Iam facing is Iam not able to capture that attribute. Because there are no objects in the object repository. Iam doing everything through dynamic programming.

Is there any way to capture an objects test property when it is not present in the object repository? GetTO property method works only for objects in the Object Repository
0 Likes
Absent Member.
Absent Member.

You would need to do something like this
below is an example for WebEdits on the page.



'Get all WebEdits on the page
Set desc = Description.Create()
desc("micclass").Value = "WebEdit"

Set WebEdits = Browser().Page().ChildObjects(desc)

For x = 0 to WebEdits.Count-1
'you need to save this somewhere
msgbox WebEdits(x).GetROProperty("name")
Next
0 Likes
Absent Member.
Absent Member.

Thanks for giving me the code. But the problem is that i need to retrieve the test object property of the object. Since the properties-label and required are test object properties I need to get those. Can you help me to retrieve a test object property of an object which is not there in object repository?
0 Likes
Absent Member.
Absent Member.

I am sorry, but I though that was what the code snippet I gave you did. For every WebEdit on the page you could get any of its object properties.

Are you asking me how to add the objects to the Object Repository?

0 Likes
Absent Member.
Absent Member.

hi...yes i know thats a snippet of the code.
In the code GETRO Property method is used. Can we use GETTO property method?
Ill try using the getTO property method and tell if its working
0 Likes
Absent Member.
Absent Member.

GetToProperty will not work. That method will only return to you what is in the test objects description IN QTP.

GetROProperty will return the properties at run time IN THE APPLICATION.
0 Likes
Absent Member.
Absent Member.

oh.. then isnt there any other way in which I can retrieve the test object property of that object? i mean GETTO property? how do I get that property?
0 Likes
Absent Member.
Absent Member.

You are getting confused by the term Test object. This is understandable since Mercury's naming convention was kind of moronic and ambiguous.

Use the Object Spy and click on the object you are interested in. You will see a list of properties pop up. Those are the Test Object properties you would see at run time. To access those properties in code you use the GetROProperty() method.

QTP accesses those application objects by creating a Description. This is basically a collection of property/value pairs that uniquely identify each object. This Description can be done in two ways, The Object Repository (OR) and Descriptive Programming. These methods are mutually exclusive. This means that if you use descriptive programming, you do NOT need an object repository. Henry showed you an example on how to do this. Read it carefully and try to understand what he is doing. I personally do not use an OR in any of my automation.

Anyway, to access or change at runtime the way QTP identifies the application object, i.e. manipulate its Description, you use the Get/SetTOProperty() method.

I hope this clears up your confusion.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.