Calling "Native" Properties and Methods

Applies to TestLeft 15.40, last modified on March 17, 2022

About

“Native” properties and methods are the ones that are available in the tested application’s source code or library, including user-defined properties and methods the application developers implemented. You can verify or change the values of internal objects, or call the native methods of these objects from your TestLeft tests.

In Desktop applications, the level of “transparency” depends on the application type. For example, .NET, WPF and Java applications are “open” to TestLeft out of the box, whereas Visual C++, Delphi and some other applications need special preparations.

In Web applications, TestLeft gets access to methods, attributes and properties defined by the DOM model and HTML standards, as well as to the methods and properties added to web page elements by the browser’s layout engine.

The exposed native members become available through the IObject interface. In the UI Spy panel, they are listed under the Available through the IObject interface category at the bottom of the list of the supported interfaces.

Native properties and methods of the tested object available through the IObject interface (.NET)

Click the image to enlarge it.

The exposed native members become available through the TestObject interface. In the UI Spy panel, they are listed under the Available through the TestObject interface category at the bottom of the list of the supported interfaces.

Native properties and methods of the tested object available through the TestObject interface (Java)

Click the image to enlarge it.

Requirements

Typically, you can access native properties and methods of most applications without any special preparations. However, in some cases, you may need to prepare your application in a special way to access its internals. The way you prepare your application depends on the application type. You can find detailed instructions in the following sections:

Example

You call native methods and properties in a specific way, via the following methods of your test object:

.NET: GetProperty<T>, SetProperty and CallMethod.

Java: getProperty, setProperty and callMethod.

You can generate the needed calls automatically in UI Spy. Right-click the needed native property or method in UI Spy, then click Copy Member Call and insert the generated code into your test. Modify the generated code, if needed.

Generating .NET code to call native properties and methods in UI Spy

Click the image to enlarge it.

Generating Java code to call native properties and methods in UI Spy

Click the image to enlarge it.

See the sample calls.

See Also

Creating TestLeft Tests
Preparing Desktop Applications for Testing
Preparing Web Applications for Testing
Methods and Properties Common for All Test Objects

Highlight search results