This functionality is supported only if you are using the Open Agent.
You can create custom classes for custom controls for which
Silk Test Classic does not offer any dedicated support. Creating custom classes offers the following advantages:
- Better locators for scripts.
- An easy way to write reusable code for the interaction with the custom control.
Example: Testing the
tabControl Infragistics control
Suppose that a custom
tab control is recognized by
Silk Test Classic as the generic class
Control. Using the custom control support of
Silk Test Classic has the following advantages:
- Better object recognition because the custom control class name can be used in a locator.
- Many objects might be recognized as
Control. The locator requires an index to identify the specific object. For example, the object might be identified by the locator
//Control[13]. When you create a custom class for this control, for example the class
UltraTabControl, you can use the locator
//UltraTabControl. By creating the custom class, you do not require the high index, which would be a fragile object identifier if the application
under test changed.
- You can implement reusable playback actions for the control in scripts.
-
When you are using custom classes, you can encapsulate the behavior for getting the contents of a grid into a method by adding
the following code to your custom class, which is the class that gets generated when you specify the custom control in the
user interface.
Typically, you can implement the methods in a custom control class in one of the following ways:
- You can use methods like
Click,
TypeKeys,
TextClick, and
TextCapture. In this example the
TextClick method is used.
- You can dynamically invoke methods on the object in the AUT.
Without using the custom classes, when you want to select a tab in your custom tab controls, you can write code like the
following:
UltraTabControl.TextClick("<TabName>")
When you are using custom classes, you can encapsulate the behavior for selecting a tab into a method by adding the following
code to your custom class, which is the class that gets generated when you specify the custom control in the user interface:
void SelectTab(string tabText)
TextClick(tabText)
The custom class looks like the following:
winclass UltraTabControl : Control
tag "[UltraTabControl]"
void SelectTab(string tabText)
TextClick(tabText)
You can now use the newly created method
SelectTab in a script like the following:
UltraTabControl.SelectTab("<TabName>")
When you define a class as a custom control, you can use the class in the same way in which you can use any built-in class,
for example the
Dialog class.