com.canoo.webtest.steps.form
Class AbstractSetFieldStep

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.canoo.webtest.steps.Step
              extended by com.canoo.webtest.steps.AbstractBrowserAction
                  extended by com.canoo.webtest.steps.form.AbstractSetFieldStep
All Implemented Interfaces:
IBrowserAction, Serializable, Cloneable
Direct Known Subclasses:
AbstractSetNamedFieldStep, SetFileField

public abstract class AbstractSetFieldStep
extends AbstractBrowserAction

Abstract class for steps which update form fields. This class handles the attributes name/formName, htmlId or xpath.

Author:
Marc Guillemot, Paul King, Denis N. Antonioli
See Also:
Serialized Form

Field Summary
static String MESSAGE_ARGUMENT_MISSING
           
static String MESSAGE_ARGUMENT_REDUNDANT
           
 
Fields inherited from class com.canoo.webtest.steps.Step
DEFAULT_DESCRIPTION, ELEMENT_ATTRIBUTE_ID, ELEMENT_ATTRIBUTE_NAME, PROPERTY_TYPE_ANT, PROPERTY_TYPE_ANT_STRICT, PROPERTY_TYPE_DEFAULT, PROPERTY_TYPE_DYNAMIC
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
AbstractSetFieldStep()
           
 
Method Summary
 void doExecute()
          Called to perform the step's functionality.
protected  List findFields(com.gargoylesoftware.htmlunit.html.HtmlForm form)
          Finds all possible input fields.
protected abstract  com.gargoylesoftware.htmlunit.html.HtmlForm findForm()
          Finds the relevant form.
 String getFieldIndex()
           
 String getForLabel()
           
 String getFormName()
           
 String getHtmlId()
           
 String getName()
           
 String getXpath()
           
protected  boolean keepField(com.gargoylesoftware.htmlunit.html.HtmlElement elt)
          Called by findFields(com.gargoylesoftware.htmlunit.html.HtmlForm) to filter out elements with the correct name but not matching some other selection criteria.
static com.gargoylesoftware.htmlunit.html.HtmlElement selectField(List fieldList, String indexStr, Step step)
          Finds the desired field by selecting either a specific field designated by indexStr or the first one if indexStr is left blank
protected abstract  void setField(com.gargoylesoftware.htmlunit.html.HtmlElement field)
          Sets a field according to the step.
 void setFieldIndex(String index)
          Set the index.
 void setForLabel(String text)
          Set the text of the label associated with the field to set.
 void setFormName(String formName)
          Set the form name.
 void setHtmlId(String htmlId)
          Set the html id.
 void setName(String name)
          Set the name.
 void setXpath(String xpath)
          Set the xpath.
protected  List trimFields(List fields)
          Apply keepField(com.gargoylesoftware.htmlunit.html.HtmlElement) to trim the list of fields found.
protected  void verifyParameters()
          Called to let the step's implementation validate its parameters.
 
Methods inherited from class com.canoo.webtest.steps.AbstractBrowserAction
setSave, setSavePrefix, setSaveResponse
 
Methods inherited from class com.canoo.webtest.steps.Step
addComputedParameters, clone, emptyParamCheck, execute, getComputedParameters, getContext, getDefaultPropertyType, getDescription, getDuration, getParameterDictionary, getStepLabel, getVerifier, getWebtestProperties, getWebtestProperties, getWebtestProperty, getWebtestProperty, handleException, hasDescription, integerParamCheck, isCompleted, isPerformingAction, isStarted, isSuccessful, notifyCompleted, notifyStarted, notifyStepResultsListeners, notifySuccess, nullParamCheck, nullResponseCheck, optionalIntegerParamCheck, paramCheck, positiveOrZeroParamCheck, setStepid, setWebtestProperty, setWebtestProperty, toString
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.canoo.webtest.interfaces.IBrowserAction
getTaskName
 

Field Detail

MESSAGE_ARGUMENT_MISSING

public static final String MESSAGE_ARGUMENT_MISSING
See Also:
Constant Field Values

MESSAGE_ARGUMENT_REDUNDANT

public static final String MESSAGE_ARGUMENT_REDUNDANT
See Also:
Constant Field Values
Constructor Detail

AbstractSetFieldStep

public AbstractSetFieldStep()
Method Detail

setName

public void setName(String name)
Set the name.

Parameters:
name -

getName

public String getName()

setForLabel

public void setForLabel(String text)
Set the text of the label associated with the field to set.

Parameters:
text - the label text

getForLabel

public String getForLabel()

getXpath

public String getXpath()

setXpath

public void setXpath(String xpath)
Set the xpath.

Parameters:
xpath -

setFormName

public void setFormName(String formName)
Set the form name.

Parameters:
formName -

getFormName

public String getFormName()

getHtmlId

public String getHtmlId()

setHtmlId

public void setHtmlId(String htmlId)
Set the html id.

Parameters:
htmlId -

setFieldIndex

public void setFieldIndex(String index)
Set the index.

Parameters:
index -

getFieldIndex

public String getFieldIndex()

doExecute

public void doExecute()
               throws SAXException,
                      IOException
Description copied from class: Step
Called to perform the step's functionality. Before calling this method, the step has been completely initialized (including expanding and verifying the parameters) and the environment notified of the start.

Specified by:
doExecute in class Step
Throws:
SAXException
IOException

setField

protected abstract void setField(com.gargoylesoftware.htmlunit.html.HtmlElement field)
                          throws IOException
Sets a field according to the step. It is up to the step's implementation to decide how to set the step.

Parameters:
field - The field to set.
Throws:
IOException

findForm

protected abstract com.gargoylesoftware.htmlunit.html.HtmlForm findForm()
Finds the relevant form.

Returns:
The found form.

findFields

protected List findFields(com.gargoylesoftware.htmlunit.html.HtmlForm form)
Finds all possible input fields. This is a generic implementation, sub-classes may want to take advantage of more specific functions.

Parameters:
form - The form to search.
Returns:
A list of candidate fields.

trimFields

protected List trimFields(List fields)
Apply keepField(com.gargoylesoftware.htmlunit.html.HtmlElement) to trim the list of fields found.

Parameters:
fields - All fields found.
Returns:
A list of candidate fields.

keepField

protected boolean keepField(com.gargoylesoftware.htmlunit.html.HtmlElement elt)
Called by findFields(com.gargoylesoftware.htmlunit.html.HtmlForm) to filter out elements with the correct name but not matching some other selection criteria.

Parameters:
elt - One of the elements with the correct name.
Returns:
True if the element is accepted.

selectField

public static com.gargoylesoftware.htmlunit.html.HtmlElement selectField(List fieldList,
                                                                         String indexStr,
                                                                         Step step)
Finds the desired field by selecting either a specific field designated by indexStr or the first one if indexStr is left blank

Parameters:
fieldList - A list of fields.
indexStr - The index of the desired field.
step - The calling step, for exception.
Returns:
The selected field

verifyParameters

protected void verifyParameters()
Description copied from class: Step
Called to let the step's implementation validate its parameters. The method is called after parameter extensions but before Step.doExecute(). This implementation does nothing, overwrite as needed.

Overrides:
verifyParameters in class Step

Copyright © 2001-2007 Canoo Engineering AG, Basel. All rights reserved.