Dynamic invoke enables you to directly call methods, retrieve properties, or set properties, on an actual instance of a control in the application under test. You can also call methods and properties that are not available in the Silk Test Classic API for this control. Dynamic invoke is especially useful when you are working with custom controls, where the required functionality for interacting with the control is not exposed through the Silk Test Classic API.
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.
control.DynamicInvoke("SetTitle", {"my new title"})
For an object of the Silk Test Classic type DataGrid, you can call all methods that MSDN defines for the type System.Windows.Forms.DataGrid.
//4Test code BOOLEAN isExpanded = (BOOLEAN) dataGrid.DynamicInvoke("IsExpanded", {3})
//4Test code INTEGER result = mainWindow.DynamicInvoke("System.String.Compare", {"a", "b"});
string cellText = dataGrid.Rows[rowIndex].Cells[columnIndex].Text;
string cellText = dataGrid.Rows[0].Cells[2];
INTEGER rowIndex = 0 INTEGER columnIndex = 2 LIST OF STRING names = { ... } "Rows" // Get the list of rows from the grid. "get_Item" // Get a specific row from the list of rows by using the indexer method. "Cells" // Get the list of cells from the the row. "get_Item" // Get a specific cell from the list of cells by using the indexer method. "Text" // Get the text of the cell. LIST OF LIST parameters = { ... } {} // Parameters for the Rows property. {rowIndex} // Parameters for the get_Item method. {} // Parameters for the Cells property. {columnIndex} // Parameters for the get_Item method. {} // Parameters for the Text property. dataGrid.DynamicInvokeMethods(names, parameters)
Silk Test Classic types includes primitive types (such as boolean, int, string), lists, and other types (such as Point and Rect).
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 struct and object parameters must be passed 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.
Call ToString on returned .NET objects to retrieve the string representation
customControl.DynamicInvoke("Reset") REAL sum = customControl.DynamicInvoke("Add",{1,2})
REAL lastResult = customControl.GetProperty("LastCalculationResult")