Access native objects, methods, and properties

This topic describes interacting with an object in your application using its native methods and properties.


If the test object methods and properties available for a particular test object do not provide the functionality you need, you can access the native methods and properties of the run-time object in your application using the relevant property/method/function for your programming language.

For example, suppose you have a Web edit test object defined in your test called searchBox. You could access the native (run-time) search box object, and then use the native isDisabled property to make sure your search box has the expected state.

IntelliSense is not available for NativeObjects, but you can query your object for the list of available methods and properties, as described below.

Additionally, make sure you are aware of these Considerations .

Back to top

Query an object to find the available methods and properties

The UFT Developer SDK provides the ability to retrieve the list of available native methods and properties for any object.

Both C# and Java return a string collection of the available members. You can write the list to a file or use the Locals or Watch debug panes to view the returned list.

In the returned list, each method has a () suffix. In some technologies and browsers, the full syntax of methods is displayed and read-only (get) properties have a [ReadOnly] suffix.

Back to top


  • Test compilation. The native operation names and argument syntax are not validated when the test is compiled.
  • Supported technologies. NativeObject support is not available for the Standard Windows and Mobile technologies.
  • Code reliability. Keep in mind that NativeObject gives you access to the actual object in your application. It is your responsibility to make sure that methods and properties you perform on the object are safe and reliable, and that any objects opened or created using native methods and properties are handled by your code. For example, if you raise a message box using a native operation, you may have to close it manually or using native object code before the test can continue to perform steps on your application.
  • C# Enumerations. If a NativeObject operation returns an enumeration, use ToString() to return the enum's value.
  • Indexers and JavaScript arrays. If you return a C# (Windows Forms or WPF) native object that has an indexer, you can access the indexer value just as you would with the object itself. The same is true for JavaScript arrays in Web applications.

    For example:

      var arr = webElement.NativeObject.array;
      arr[1] = 100;
      arrValue = arr[0];

    You can also work with multidimensional indexers:

    • If you are using the .NET SDK, you can reference it as you would any multidimensional indexer.  For example: myNativeObject[1,2]

    • To retrieve or set a multidimensional indexer using the Java SDK, use the NativeObject getItem and setItem methods and supply the array of indexes you want to retrieve or set.

  • JavaScript SDK syntax. Any operation of the native object is an asynchronic operation even if it looks like a normal assignment.

    For example:

    edit.nativeObject().then(function(e) {
        e.value = "BBB";

    In this case, value is a property of the native object, and assigning a value to it invokes the get method of the property, which in this case is an asynchronic operation.

    Synchronization of such methods occurs the same way as synchronization of operations on the test object, meaning that each operation on the native object is performed only after the previous operation is completed.

    Note that just as accessing a non-existing key on a JavaScript object does not fail, accessing a non-existing property of the native object does not fail either. This is unlike C# (or Java) where, in such a case, the object is expected to fail.

    For example, the operation:

    nativeObject.nonExsitingKey = 8;

    creates a new key for nativeObject called nonExsitingKey, and sets its value to 8, while in C# (or Java) such an operation is expected to fail.

  • Web. When you use the NativeObject property on a Web-based object, you get a reference to the DOM object, meaning all methods and properties that can be performed on the DOM object are available. However, keep in mind that many DOM methods and properties are browser-specific and such could affect the cross-browser viability of your test.
  • SAP GUI for Windows. The NativeObject returned for a SAP.GUI object gives access to the native methods and properties of the SAP Scripting API. For more information on these methods and properties, refer to your SAP Scripting API documentation.
  • .NET Windows Forms. If a native method's return value or a native property's value is a structure, a string value representing the structure is returned.

Back to top

See also: