Accessing Native Properties and Operations In QTP

Accessing Native Properties and Operations


If the test object operations and identification properties available for a particular test object do not provide the functionality you need, you can access the native operations and properties of any run-time object in your application using the Object property.


You can use the statement completion feature with object properties to view a list of the available native operations and properties of an object. For more information on the statement completion option, see Generating Statements in the Expert View or in a Function Library.


Tip: If the object is a Web object, you can also reference its native properties in programmatic descriptions using the attribute/property notation. For more information, see Accessing User-Defined Properties of Web Objects.

For more information, see:


  • Retrieving Native Properties


  • Activating Native Operations


  • Accessing User-Defined Properties of Web Objects

Retrieving Native Properties


You can use the Object property to access the native properties of any run-time object. For example, you can retrieve the current value of the ActiveX calendar's internal Day property as follows:

Dim MyDay

Set MyDay=Browser("index").Page("Untitled").ActiveX("MSCAL.Calendar.7").Object.Day 

Activating Native Operations

You can use the Object property to activate the internal operations of any run-time object. For example, you can activate the native focus method of the edit box as follows:

Dim MyWebEdit

Set MyWebEdit=Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Object

MyWebEdit.focus


Accessing User-Defined Properties of Web Objects

You can use the attribute/ notation to access native properties of Web objects and use these properties to identify such objects with programmatic descriptions.

For example, suppose a Web page has the same company logo image in two places on the page:

IMG src="logo.gif" LogoID="122"

IMG src="logo.gif" LogoID="123"

You could identify the image that you want to click using a programmatic description by including the user-defined property LogoID in the description as follows:

Browser("Mercury Tours").Page("Find Flights").Image("src:=logo.gif","attribute/LogoID:=123").Click 68, 12


The below stuff is very important and very frequently used by any QTP programmer in Object identification using QTP.

Post a Comment

Previous Post Next Post