I have the following HTML tag, which QTP correctly identifies as a WebEdit
object:
<input style="width: 228px;" aria-describedby="x-auto-0" _id="Tenant" name=""
tabindex="1" id="x-auto-23-input" class="x-form-field x-form-text x-form-invalid"
type="text">
How do I get the _id
property from the HTML tag into an object property in QTP? I've used the Object Identification dialog to add both _id
and html _id
properties to the WebEdit
class. However neither are filled in when I use either the Object Spy or the Recorder.
Note that the page being tested contains a number of these text inputs, each with a blank name
but descriptive _id
. I'm trying to get the _id
into a property of WebEdit so I can refer to a particular text box by Browser("Browser").Page("Page"),WebEdit("_id:=Tenant")
.
Best Answer
HTML attributes can be obtained by using the
.Object.GetAttribute()
function. This is particularly useful for obtaining non-standard attributes (i.e., "_id").The attribute "id" aligns with the Runtime Object Property "html id", so that can be obtained using
GetROProperty()
or the above method.An example of using these methods is below:
To use descriptive programming to access an object, you can use the
attribute/
notation as well as regular expressions. For example:By default, the .Object methods and properties are not exposed for web elements in the Debug Viewer. It is possible to enhance QTP debugging by registering the Process Debug Manager (PDM) which is included in IE8. This will help you discover additional properties and methods that are available in QTP by using
.Object
. For more information on enhancing debugging in QTP 11, please see the following article: http://northwaysolutions.com/blog/qtp-11-how-to-enable-enhanced-debugging-features/