This section covers how to write custom functional points specific for the Watij plug-in..
Please be sure to read the Jameleon Custom Functional Points section on the main Jameleon documents area before continuing here. Many important principles are explained there.
While the provided tags may be sufficient to test most web applications, it is recommended to write custom tags that at the very least represent each action or form in your application.
All Watij plug-in functional points must extend WatijFunctionTag. Extending this class, gives you access to the session (IE object) and a few helper methods. Please see the javadocs provided at the link above for a detailed list of provided methods. For examples, please see the source code for the provided tags.
Usually, custom tags include filling out a form and clicking on the appropriate button. Below is an example of this.
package net.sf.jameleon.plugin.watij.acceptance; import net.sf.jameleon.plugin.watij.WatijFunctionTag; import static watij.finders.SymbolFactory.*; /** * Fills out a form and submits it. * * @jameleon.function name="watij-form-test" type="action" */ public class FormTestTag extends WatijFunctionTag{ /** * @jameleon.attribute */ protected String username; /** * @jameleon.attribute */ protected String password; /** * @jameleon.attribute */ protected boolean someCheckbox; public void testBlock(){ ie().textField(name, usernameField).set(username); ie().textFiled(name, passwordField).set(password); ie().checkbox(name, someCheckboxField).set(someCheckbox); ie().button(name, submitButtonName).click(); } /////////////////////////////////////////////////////////////////////////////////////////////// // For Field Definitions // These all have default values and contain attributes we wish to make available to be set. // However, for the most part, these are attributes that hide the form specifics from the user. /////////////////////////////////////////////////////////////////////////////////////////////// /** * @jameleon.attribute default="userid" */ protected String usernameField; /** * @jameleon.attribute default="password" */ protected String passwordField; /** * @jameleon.attribute default="ed1" */ protected String someCheckboxField; /** * @jameleon.attribute default="Go" */ protected String submitButtonName; }