| java.lang.Object com.meterware.httpunit.ParameterHolder com.meterware.httpunit.WebRequestSource com.meterware.httpunit.WebForm
WebForm | public class WebForm extends WebRequestSource (Code) | | This class represents a form in an HTML page. Users of this class may examine the parameters
defined for the form, the structure of the form (as a DOM), or the text of the form. They
may also create a
WebRequest to simulate the submission of the form.
author: Russell Gold |
Method Summary | |
void | addFormControl(FormControl control) | protected void | addPresetParameter(String name, String value) Records a parameter defined by including it in the destination URL. | WebResponse | doFormSubmit(SubmitButton button) Submits the form without also invoking the button's "onclick" event. | WebResponse | doFormSubmit(SubmitButton button, int x, int y) | public String | getAction() Returns the action defined for this form. | public Button | getButton(HTMLElementPredicate predicate, Object criteria) | public Button | getButtonWithID(String buttonID) Convenience method which returns the button with the specified ID. | public Button[] | getButtons() Returns an array containing all of the buttons defined for this form. | public String | getCharacterSet() Returns the character set encoding for this form. | FormControl | getControlWithID(String id) Returns the form control which is part of this form with the specified ID. | protected String | getEmptyParameterValue() | public String | getMethod() Returns the method defined for this form. | public int | getNumTextParameters(String name) Returns the number of text parameters in this form with the specified name. | public String[] | getOptionValues(String name) Returns the option values defined for the specified parameter name. | public String[] | getOptions(String name) Returns the displayed options defined for the specified parameter name. | public String[] | getParameterNames() Returns an array containing the names of the parameters defined for this form. | public String | getParameterValue(String name) Returns the default value of the named parameter. | public String[] | getParameterValues(String name) Returns the multiple default values of the named parameter. | public WebRequest | getRequest(String submitButtonName, String submitButtonValue) Creates and returns a web request which will simulate the submission of this form with a button with the specified name and value. | public WebRequest | getRequest(String submitButtonName) Creates and returns a web request which will simulate the submission of this form with a button with the specified name. | public WebRequest | getRequest(SubmitButton button) Creates and returns a web request which will simulate the submission of this form by pressing the specified button. | public WebRequest | getRequest(SubmitButton button, int x, int y) Creates and returns a web request which will simulate the submission of this form by pressing the specified button. | public WebRequest | getRequest() Creates and returns a web request which will simulate the submission of this form with an unnamed submit button. | public ScriptableDelegate | getScriptableDelegate() Returns the scriptable delegate. | public Scriptable | getScriptableObject() Returns an object which provides scripting access to this form. | public SubmitButton | getSubmitButton(String name) Returns the submit button defined in this form with the specified name. | public SubmitButton | getSubmitButton(String name, String value) Returns the submit button defined in this form with the specified name and value. | public SubmitButton | getSubmitButtonWithID(String ID) Returns the submit button defined in this form with the specified ID. | public SubmitButton[] | getSubmitButtons() Returns an array containing the submit buttons defined for this form. | public boolean | hasParameterNamed(String soughtName) Returns true if a parameter with given name exists in this form. | public boolean | hasParameterStartingWithPrefix(String prefix) | public boolean | isDisabledParameter(String name) Returns true if the named parameter is disabled. | public boolean | isFileParameter(String name) Returns true if the named parameter accepts files for upload. | public boolean | isHiddenParameter(String name) Returns true if the named parameter is hidden. | public boolean | isMultiValuedParameter(String name) Returns true if the named parameter accepts multiple values. | public boolean | isReadOnlyParameter(String name) Returns true if the named parameter is read-only. | public boolean | isSubmitAsMime() Returns true if this form is to be submitted using mime encoding (the default is URL encoding). | public boolean | isTextParameter(String name) Returns true if the named parameter accepts free-form text. | FormControl | newFormControl(Node child) | public WebRequest | newUnvalidatedRequest(SubmitButton button) Creates and returns a web request which includes the specified button. | public WebRequest | newUnvalidatedRequest(SubmitButton button, int x, int y) Creates and returns a web request which includes the specified button and position. | public WebRequest | newUnvalidatedRequest() Creates and returns a web request based on the current state of this form. | void | recordParameters(ParameterProcessor processor) Iterates through the parameters in this holder, recording them in the supplied parameter processor. | void | recordPredefinedParameters(ParameterProcessor processor) Iterates through the fixed, predefined parameters in this holder, recording them in the supplied parameter processor.\
These parameters always go on the URL, no matter what encoding method is used. | public void | removeParameter(String name) Removes a parameter name from this collection. | public void | reset() Resets all parameters to their initial values. | void | selectImageButtonPosition(SubmitButton imageButton, int x, int y) Specifies the position at which an image button (if any) was clicked. | public void | setCheckbox(String name, boolean state) Sets the value of the specified checkbox parameter. | public void | setCheckbox(String name, String value, boolean state) Sets the value of the specified checkbox parameter. | public void | setParameter(String name, String value) Sets the value of a parameter in this form. | public void | setParameter(String name, String[] values) Sets the multiple values of a parameter in this form. | public void | setParameter(String name, UploadFileSpec[] files) Sets the multiple values of a file upload parameter in a web request. | public void | setParameter(String name, File file) Sets the single value of a file upload parameter in this form. | void | setSubmitAsMime(boolean mimeEncoded) | public WebResponse | submit() Submits this form using the web client from which it was originally obtained. | public WebResponse | submit(SubmitButton button) Submits this form using the web client from which it was originally obtained. | public WebResponse | submit(SubmitButton button, int x, int y) Submits this form using the web client from which it was originally obtained. | public WebResponse | submitNoButton() Submits this form using the web client from which it was originally obtained, ignoring any buttons defined for the form. | protected WebResponse | submitRequest(String event, WebRequest request) | public void | toggleCheckbox(String name) Toggles the value of the specified checkbox parameter. | public void | toggleCheckbox(String name, String value) Toggles the value of the specified checkbox parameter. |
addPresetParameter | protected void addPresetParameter(String name, String value)(Code) | | Records a parameter defined by including it in the destination URL. Ignores any parameters whose name matches
a form control.
|
getAction | public String getAction()(Code) | | Returns the action defined for this form.
|
getButtonWithID | public Button getButtonWithID(String buttonID)(Code) | | Convenience method which returns the button with the specified ID.
|
getButtons | public Button[] getButtons()(Code) | | Returns an array containing all of the buttons defined for this form.
|
getCharacterSet | public String getCharacterSet()(Code) | | Returns the character set encoding for this form.
|
getControlWithID | FormControl getControlWithID(String id)(Code) | | Returns the form control which is part of this form with the specified ID.
|
getEmptyParameterValue | protected String getEmptyParameterValue()(Code) | | |
getMethod | public String getMethod()(Code) | | Returns the method defined for this form.
|
getNumTextParameters | public int getNumTextParameters(String name)(Code) | | Returns the number of text parameters in this form with the specified name.
|
getOptionValues | public String[] getOptionValues(String name)(Code) | | Returns the option values defined for the specified parameter name.
|
getOptions | public String[] getOptions(String name)(Code) | | Returns the displayed options defined for the specified parameter name.
|
getParameterNames | public String[] getParameterNames()(Code) | | Returns an array containing the names of the parameters defined for this form.
|
getParameterValue | public String getParameterValue(String name)(Code) | | Returns the default value of the named parameter. If the parameter does not exist returns null.
|
getParameterValues | public String[] getParameterValues(String name)(Code) | | Returns the multiple default values of the named parameter.
|
getRequest | public WebRequest getRequest(String submitButtonName, String submitButtonValue)(Code) | | Creates and returns a web request which will simulate the submission of this form with a button with the specified name and value.
|
getRequest | public WebRequest getRequest(String submitButtonName)(Code) | | Creates and returns a web request which will simulate the submission of this form with a button with the specified name.
|
getRequest | public WebRequest getRequest(SubmitButton button)(Code) | | Creates and returns a web request which will simulate the submission of this form by pressing the specified button.
If the button is null, simulates the pressing of the default button.
|
getRequest | public WebRequest getRequest(SubmitButton button, int x, int y)(Code) | | Creates and returns a web request which will simulate the submission of this form by pressing the specified button.
If the button is null, simulates the pressing of the default button.
|
getRequest | public WebRequest getRequest()(Code) | | Creates and returns a web request which will simulate the submission of this form with an unnamed submit button.
|
getScriptableObject | public Scriptable getScriptableObject()(Code) | | Returns an object which provides scripting access to this form.
|
getSubmitButton | public SubmitButton getSubmitButton(String name)(Code) | | Returns the submit button defined in this form with the specified name.
If more than one such button exists, will return the first found.
If no such button is found, will return null.
|
getSubmitButton | public SubmitButton getSubmitButton(String name, String value)(Code) | | Returns the submit button defined in this form with the specified name and value.
If more than one such button exists, will return the first found.
If no such button is found, will return null.
|
getSubmitButtonWithID | public SubmitButton getSubmitButtonWithID(String ID)(Code) | | Returns the submit button defined in this form with the specified ID.
If more than one such button exists, will return the first found.
If no such button is found, will return null.
|
getSubmitButtons | public SubmitButton[] getSubmitButtons()(Code) | | Returns an array containing the submit buttons defined for this form.
|
hasParameterNamed | public boolean hasParameterNamed(String soughtName)(Code) | | Returns true if a parameter with given name exists in this form.
|
hasParameterStartingWithPrefix | public boolean hasParameterStartingWithPrefix(String prefix)(Code) | | Returns true if a parameter starting with a given name exists,
|
isDisabledParameter | public boolean isDisabledParameter(String name)(Code) | | Returns true if the named parameter is disabled. If more than one control exists with the same name,
will return true only if all such controls are read-only.
|
isFileParameter | public boolean isFileParameter(String name)(Code) | | Returns true if the named parameter accepts files for upload.
|
isHiddenParameter | public boolean isHiddenParameter(String name)(Code) | | Returns true if the named parameter is hidden. If more than one control exists with the same name,
will return true only if all such controls are hidden.
|
isMultiValuedParameter | public boolean isMultiValuedParameter(String name)(Code) | | Returns true if the named parameter accepts multiple values.
|
isReadOnlyParameter | public boolean isReadOnlyParameter(String name)(Code) | | Returns true if the named parameter is read-only. If more than one control exists with the same name,
will return true only if all such controls are read-only.
|
isSubmitAsMime | public boolean isSubmitAsMime()(Code) | | Returns true if this form is to be submitted using mime encoding (the default is URL encoding).
|
isTextParameter | public boolean isTextParameter(String name)(Code) | | Returns true if the named parameter accepts free-form text.
|
newUnvalidatedRequest | public WebRequest newUnvalidatedRequest(SubmitButton button)(Code) | | Creates and returns a web request which includes the specified button. If no button is specified, will include
the default button, if any. No parameter validation will be done on the returned request and no scripts
will be run when it is submitted.
|
newUnvalidatedRequest | public WebRequest newUnvalidatedRequest(SubmitButton button, int x, int y)(Code) | | Creates and returns a web request which includes the specified button and position. If no button is specified,
will include the default button, if any. No parameter validation will be done on the returned request
and no scripts will be run when it is submitted.
|
newUnvalidatedRequest | public WebRequest newUnvalidatedRequest()(Code) | | Creates and returns a web request based on the current state of this form. No parameter validation will be done
and there is no guarantee over the order of parameters transmitted.
|
recordParameters | void recordParameters(ParameterProcessor processor) throws IOException(Code) | | Iterates through the parameters in this holder, recording them in the supplied parameter processor.
|
recordPredefinedParameters | void recordPredefinedParameters(ParameterProcessor processor) throws IOException(Code) | | Iterates through the fixed, predefined parameters in this holder, recording them in the supplied parameter processor.\
These parameters always go on the URL, no matter what encoding method is used.
|
removeParameter | public void removeParameter(String name)(Code) | | Removes a parameter name from this collection.
|
reset | public void reset()(Code) | | Resets all parameters to their initial values.
|
selectImageButtonPosition | void selectImageButtonPosition(SubmitButton imageButton, int x, int y)(Code) | | Specifies the position at which an image button (if any) was clicked.
|
setCheckbox | public void setCheckbox(String name, boolean state)(Code) | | Sets the value of the specified checkbox parameter.
Parameters: name - the name of the checkbox parameter Parameters: state - the new state of the checkbox throws: IllegalArgumentException - if the specified parameter is not a checkbox or there is more than onecontrol with that name. since: 1.5.4 |
setCheckbox | public void setCheckbox(String name, String value, boolean state)(Code) | | Sets the value of the specified checkbox parameter.
Parameters: name - the name of the checkbox parameter Parameters: value - of the checkbox parameter Parameters: state - the new state of the checkbox throws: IllegalArgumentException - if the specified parameter is not a checkbox or if there is no checkboxwith the specified name and value. since: 1.6 |
setParameter | public void setParameter(String name, String value)(Code) | | Sets the value of a parameter in this form.
|
setParameter | public void setParameter(String name, String[] values)(Code) | | Sets the multiple values of a parameter in this form. This is generally used when there are multiple
controls with the same name in the form.
|
setParameter | public void setParameter(String name, UploadFileSpec[] files)(Code) | | Sets the multiple values of a file upload parameter in a web request.
|
setSubmitAsMime | void setSubmitAsMime(boolean mimeEncoded)(Code) | | |
submit | public WebResponse submit(SubmitButton button) throws IOException, SAXException(Code) | | Submits this form using the web client from which it was originally obtained.
Will usually return the result of that submission; however, if the submit button's 'onclick'
or the form's 'onsubmit' event is triggered and
inhibits the submission, will return the updated contents of the frame containing this form.
|
submit | public WebResponse submit(SubmitButton button, int x, int y) throws IOException, SAXException(Code) | | Submits this form using the web client from which it was originally obtained.
Will usually return the result of that submission; however, if the submit button's 'onclick'
or the form's 'onsubmit' event is triggered and
inhibits the submission, will return the updated contents of the frame containing this form.
since: 1.6 |
submitNoButton | public WebResponse submitNoButton() throws SAXException, IOException(Code) | | Submits this form using the web client from which it was originally obtained, ignoring any buttons defined for the form.
since: 1.6 |
toggleCheckbox | public void toggleCheckbox(String name)(Code) | | Toggles the value of the specified checkbox parameter.
Parameters: name - the name of the checkbox parameter throws: IllegalArgumentException - if the specified parameter is not a checkbox or there is more than onecontrol with that name. since: 1.5.4 |
toggleCheckbox | public void toggleCheckbox(String name, String value)(Code) | | Toggles the value of the specified checkbox parameter.
Parameters: name - the name of the checkbox parameter Parameters: value - of the checkbox parameter throws: IllegalArgumentException - if the specified parameter is not a checkbox or if there is no checkboxwith the specified name and value. since: 1.6 |
|
|