Introduction?

This section covers how to write custom functional points specific for the Selenium 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 will likely 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.

How to Write a Custom Functional Point Using the Selenium Plug-in

All Selenium plug-in functional points must extend SeleniumFunctionTag. Extending this class, gives you access to the session 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.

Quick Tips

Submitting Forms

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.selenium.acceptance;

import net.sf.jameleon.plugin.selenium.SeleniumFunctionTag;

/**
 * Fills out a form and submits it.
 * 
 * @jameleon.function name="selenium-form-test" type="action"
 */
public class FormTestTag extends SeleniumFunctionTag{

    /**
     * @jameleon.attribute
     */
    protected String username;
    /**
     * @jameleon.attribute
     */
    protected String password;
    /**
     * @jameleon.attribute
     */
    protected boolean someCheckbox;

    public void testBlock(){
        session.type(usernameField, username);
        session.type(passwordField, password);
        if (someCheckbox){
            session.check(someCheckboxField, someCheckbox);
        }else(
            session.uncheck(someCheckboxField, someCheckbox);
        }
        session.click("name="+submitButtonName);
    }

///////////////////////////////////////////////////////////////////////////////////////////////
// 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;
    /**
     * @jameleon.attribute default="sample"
     */
    protected String formName;
}
If you look at the javadocs for SeleniumFunctionTag, you will see access to the session object. Everything from there is simply calling methods defined in Selenium.