Package com.meterware.httpunit
Class WebLink
java.lang.Object
com.meterware.httpunit.WebRequestSource
com.meterware.httpunit.WebLink
- All Implemented Interfaces:
HTMLElement
,com.meterware.httpunit.protocol.ParameterCollection
,ScriptingEventHandler
This class represents a link in an HTML page. Users of this class may examine the
structure of the link (as a DOM), or create a
WebRequest
to simulate clicking
on the link.- Author:
- Russell Gold, <a href="mailto:benoit.xhenseval@avondi.com>Benoit Xhenseval
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HTMLElementPredicate
Predicate to match part or all of a link's contained text.static final HTMLElementPredicate
Predicate to match a link's ID.static final HTMLElementPredicate
Predicate to match a link's name.static final HTMLElementPredicate
Predicate to match a link's text exactly.static final HTMLElementPredicate
Predicate to match part or all of a link's URL string. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addPresetParameter
(String name, String value) Records a parameter defined by including it in the destination URL.asText()
Deprecated.as of 1.6, use #getText insteadclick()
Submits a request as though the user had clicked on this link.protected String
String[]
Returns an array containing the names of any parameters defined as part of this link's URL.String[]
getParameterValues
(String name) Returns the multiple default values of the named parameter.Creates and returns a web request which will simulate clicking on this link.getText()
Returns the text value of this link.Returns the URL referenced by this link.void
Simulates moving the mouse over the link.void
recordParameters
(com.meterware.httpunit.protocol.ParameterProcessor processor) Iterates through the parameters in this holder, recording them in the supplied parameter processor.protected void
setDestination
(String destination) Methods inherited from class com.meterware.httpunit.WebRequestSource
doEvent, doEventScript, getAttribute, getBaseResponse, getBaseURL, getClassName, getCurrentFrameContents, getDestination, getDOMSubtree, getElement, getFragmentIdentifier, getFrame, getHTMLPage, getID, getName, getNode, getPageFrame, getParentDelegate, getRelativeURL, getScriptingHandler, getTagName, getTarget, getTitle, handleEvent, isSupportedAttribute, loadDestinationParameters, removeAttribute, setAttribute, setTargetAttribute, submitRequest, submitRequest
-
Field Details
-
MATCH_URL_STRING
Predicate to match part or all of a link's URL string. -
MATCH_TEXT
Predicate to match a link's text exactly. -
MATCH_CONTAINED_TEXT
Predicate to match part or all of a link's contained text. -
MATCH_ID
Predicate to match a link's ID. -
MATCH_NAME
Predicate to match a link's name.
-
-
Method Details
-
getURLString
Returns the URL referenced by this link. This may be a relative URL. It will not include any fragment identifier. -
getText
Returns the text value of this link.- Specified by:
getText
in interfaceHTMLElement
- Overrides:
getText
in classWebRequestSource
- Since:
- 1.6
-
asText
Deprecated.as of 1.6, use #getText insteadReturns the text value of this link. -
click
Submits a request as though the user had clicked on this link. Will also fire the 'onClick', 'onMouseDown' and 'onMouseUp' event if defined. Returns the updated contents of the frame containing the link. Note that if the click updates a different frame, that frame will not be returned by this method.- Throws:
IOException
SAXException
-
mouseOver
public void mouseOver()Simulates moving the mouse over the link. Will fire the 'onMouseOver' event if defined. -
newScriptable
-
getRequest
Creates and returns a web request which will simulate clicking on this link.- Specified by:
getRequest
in classWebRequestSource
-
getParameterNames
Returns an array containing the names of any parameters defined as part of this link's URL.- Specified by:
getParameterNames
in classWebRequestSource
-
getParameterValues
Returns the multiple default values of the named parameter.- Specified by:
getParameterValues
in classWebRequestSource
-
addPresetParameter
Description copied from class:WebRequestSource
Records a parameter defined by including it in the destination URL. The value can be null, if the parameter name was not specified with an equals sign.- Specified by:
addPresetParameter
in classWebRequestSource
-
getEmptyParameterValue
- Specified by:
getEmptyParameterValue
in classWebRequestSource
-
setDestination
- Overrides:
setDestination
in classWebRequestSource
-
recordParameters
public void recordParameters(com.meterware.httpunit.protocol.ParameterProcessor processor) throws IOException Iterates through the parameters in this holder, recording them in the supplied parameter processor.- Throws:
IOException
-