Dynamically Invoking Silverlight Methods

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 Silverlight objects with the DynamicInvoke method. To retrieve a list of supported dynamic methods for a Silverlight 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 Silverlight 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 Silverlight control, use the GetPropertyList() method.

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

Supported Parameter Types

All built-in Silk Test Classic types
Silk Test Classic types include primitive types, for example boolean, int, and string, lists, and other types, for example 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 .NET enum type System.Windows.Visiblity you can use the string values of Visible, Hidden, or Collapsed.
.NET structs and objects
Pass .NET struct and object parameters as a list. The elements in the list must match one constructor for the .NET object in the test application. For example, if the method expects a parameter of the .NET type System.Windows.Vector, you can pass a list with two integers. This works because the System.Windows.Vector type has a constructor with two integer arguments.
Other controls
Control parameters can be passed as TestObject.

Returned Values

The following values are returned for properties and methods that have a return value:
  • The correct value for all built-in Silk Test Classic types.

  • All methods that have no return value return NULL.

  • A string for all other types.

    To retrieve this string representation, call the ToString() method on returned .NET objects in the application under test.

Example

A TabItem in Silverlight, which is an item in a TabControl.

tabItem.DynamicInvoke("SelectionItemPattern.Select")
mySilverligtObject.GetProperty("IsPassword")