Dynamically Invoking Java Methods

This functionality is supported only if you are using the Open Agent.

You can call methods, retrieve properties, and set properties on controls that Silk Test Classic does not expose by using the dynamic invoke feature. This feature is useful for working with custom controls and for working with controls that Silk Test Classic supports without customization.

Call dynamic methods on objects with the DynamicInvoke method. To retrieve a list of supported dynamic methods for a control, use the GetDynamicMethodList() method.

Call multiple dynamic methods on objects with the DynamicInvokeMethods method. To retrieve a list of supported dynamic methods for a control, use the GetDynamicMethodList method.

Retrieve dynamic properties with the GetProperty method and set dynamic properties with the SetProperty() method. To retrieve a list of supported dynamic properties for a control, use the GetPropertyList() method.

Note: Typically, most properties are read-only and cannot be set.

Supported Methods and Properties

The following methods and properties can be called:
  • Methods and properties that Silk Test Classic supports for the control.
  • All public methods of the SWT, AWT, or Swing widget.
  • If the control is a custom control that is derived from a standard control, all methods and properties from the standard control can be called.

Supported Parameter Types

The following parameter types are supported:
All built-in Silk Test Classic types.
Silk Test Classic types includes primitive types (such as boolean, int, string), lists, and other types (such as Point and Rect).
Enum types.
Enum parameters must be passed as string. The string must match the name of an enum value. For example, if the method expects a parameter of the enum type, java.sql.ClientInfoStatus you can use the string values of REASON_UNKNOWN, REASON_UNKNOWN_PROPERTY, REASON_VALUE_INVALID, or REASON_VALUE_TRUNCATED.

Example

A custom calculator control has a Reset method and an Add method, which performs an addition of two numbers. You can use the following code to call the methods directly from your tests:
customControl.Invoke("Reset")
REAL sum = customControl.DynamicInvoke("Add",{1,2})