Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Absent Member.. vzamoraz Absent Member..
Absent Member..
2058 views

QTP/UFT support tip: How to access the Object methods and properties.

Some controls, such as Java, ActiveX, .Net and Web controls, have their own native properties and methods. Is there a way to use these properties and methods?

 

The Object Spy dialog is capable of showing a control's internal methods/properties by selecting the "Native/Run-time" option.

However if you're trying to access the control's internal methods/properties programmatically, it will be required to use the Object property to access the properties/methods. This property is available to many but not all of QuickTest Professional's test object classes. You should check the QuickTest Professional Object Model Reference for information on whether the control supports the Object property.

If desired, the Step Generator can help accessing the internal methods/properties (with the Object property) by selecting "Native/Run-time operations".

 The Object property accesses the internal methods and properties of the specified object.

test_class.Object.method

test_class.Object.property

 

method An internal method for the specified test object. property An internal property of the specified test object.

Note: The properties and methods that are available with the .Object property come directly from the control in your application. Because of this, Mercury does not have any information (documenation) on what they do. If you need additional information on these properties and methods, you should consult with your developers.

Example 1:
' To call the getBounds method for a JavaButton, you would use the following statement in your test script:
Set rect=Browser("Browser").Page("PushButtonDemo").JavaApplet("pushbutton.html").JavaButton("Enter").Object.getBounds()

Example 2:
' To get the product version of a .Net checkbox, you would access the checkbox's ProductVersion property:
msgbox SwfWindow(".NET Windows Controls").SwfCheckBox("Check").Object.ProductVersion

To get the list of native properties and methods available for the control, you can use the Object Spy:
1. Go to Tools -> Object Spy.
2. Spy on the control.
3. Select the "Run-time Object Properties" radio button.

If the object class supports the .Object property, the Property and Method tabs in the Object Spy will be populated. If the object class does not support the .Object property, the tabs will display a message similar to the following:

"<Class type> objects do not support run-time object properties/methods."

If properties or methods are listed, continue with step 4.

4. Select the desired tab. The Properties tab will list the available properities and their values for the currently selected object. The Methods tab will list the methods that are available to the selected object.
5. Search the list for the property or method which will meet your needs. Once you have selected a property or method that will meet your needs, use it in the script.
6. Switch to Expert view.
7. Enter the object heirarchy into the script. The easiest way to do this is to record an action on the object and then remove the method (and arguments) recorded.

Example:
' The recorded statement looks like:
Browser("Browser").Page("Page").WebList("u").Select "Directory"
' Change it to:
Browser("Browser").Page("Page").WebList("u")

8. Add .Object followed by the method or property you want.

Example:
' Get the selectedindex property of the WebList object.
msgbox Browser("Browser").Page("Page").WebList("u").Object.SelectedIndex

For more information, refer to the QuickTest Professional User's Guide (QuickTest Professional User's Guide -> Advanced Features -> Working with the Expert View -> Accessing Run-Time Object Properties and Methods) and the QuickTest Professional Object Model Reference.

 

HP support
If you find that this or any post resolves your issue, mark it as an accepted solution.

 

Note: The Opinions expressed in my post are mine alone, and do not reflect the opinions of my employer. No warranties express or implied for any answered posted.

 

Labels (1)
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.