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.
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.
' To call the getBounds method for a JavaButton, you would use the following statement in your test script:
' 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.
' The recorded statement looks like:
' Change it to:
8. Add .Object followed by the method or property you want.
' Get the selectedindex property of the WebList object.
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.
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.