You can create specific automation support for the custom control. This additional automation support provides recording support and more powerful play-back support. To create automation support, the test application must be modified and the Open Agent must be extended.
After the test application has been modified and includes automation support, perform the following steps:
package customcontrols; import com.borland.silktest.jtf.Desktop; import com.borland.silktest.jtf.common.JtfObjectHandle; import com.borland.silktest.jtf.flex.FlexBox; /** * Implementation of the FlexSpinner Custom Control. */ public class FlexSpinner extends FlexBox { protected FlexSpinner(JtfObjectHandle handle, Desktop desktop) { super(handle, desktop); } @Override protected String getCustomTypeName() { return "FlexSpinner"; } public Integer getLowerBound() { return (Integer) getProperty("lowerBound"); } public Integer getUpperBound() { return (Integer) getProperty("upperBound"); } public Integer getValue() { return (Integer) getProperty("Value"); } public void setValue(Integer Value) { setProperty("Value", Value); } public Integer getStepSize() { return (Integer) getProperty("stepSize"); } public void increment(Integer steps) { invoke("Increment", steps); } public void decrement(Integer steps) { invoke("Decrement", steps); } }
FlexSpinner=customcontrols.FlexSpinnerThe code to the left of the equals sign must be the name of custom control as defined in the XML file. The code to the right of the equals sign must be the fully qualified name of the Java class for the custom control. Now you have full record and playback support when using the custom control in Silk4J.
desktop.<FlexSpinner>find("//FlexSpinner[@caption='index:1']").increment(3);
desktop.<FlexSpinner>find("//FlexSpinner[@caption='index:1']").setValue(3);