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
public class WebLink extends WebRequestSource
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 aWebRequestto simulate clicking on the link.- Author:
- Russell Gold,
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classWebLink.Scriptable
-
Field Summary
Fields Modifier and Type Field Description static HTMLElementPredicateMATCH_CONTAINED_TEXTPredicate to match part or all of a link's contained text.static HTMLElementPredicateMATCH_IDPredicate to match a link's ID.static HTMLElementPredicateMATCH_NAMEPredicate to match a link's name.static HTMLElementPredicateMATCH_TEXTPredicate to match a link's text exactly.static HTMLElementPredicateMATCH_URL_STRINGPredicate to match part or all of a link's URL string.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddPresetParameter(java.lang.String name, java.lang.String value)Records a parameter defined by including it in the destination URL.java.lang.StringasText()Deprecated.as of 1.6, use #getText insteadWebResponseclick()Submits a request as though the user had clicked on this link.protected java.lang.StringgetEmptyParameterValue()java.lang.String[]getParameterNames()Returns an array containing the names of any parameters defined as part of this link's URL.java.lang.String[]getParameterValues(java.lang.String name)Returns the multiple default values of the named parameter.WebRequestgetRequest()Creates and returns a web request which will simulate clicking on this link.java.lang.StringgetText()Returns the text value of this link.java.lang.StringgetURLString()Returns the URL referenced by this link.voidmouseOver()Simulates moving the mouse over the link.ScriptableDelegatenewScriptable()voidrecordParameters(com.meterware.httpunit.protocol.ParameterProcessor processor)Iterates through the parameters in this holder, recording them in the supplied parameter processor.protected voidsetDestination(java.lang.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 Detail
-
MATCH_URL_STRING
public static final HTMLElementPredicate MATCH_URL_STRING
Predicate to match part or all of a link's URL string.
-
MATCH_TEXT
public static final HTMLElementPredicate MATCH_TEXT
Predicate to match a link's text exactly.
-
MATCH_CONTAINED_TEXT
public static final HTMLElementPredicate MATCH_CONTAINED_TEXT
Predicate to match part or all of a link's contained text.
-
MATCH_ID
public static final HTMLElementPredicate MATCH_ID
Predicate to match a link's ID.
-
MATCH_NAME
public static final HTMLElementPredicate MATCH_NAME
Predicate to match a link's name.
-
-
Method Detail
-
getURLString
public java.lang.String getURLString()
Returns the URL referenced by this link. This may be a relative URL. It will not include any fragment identifier.
-
getText
public java.lang.String getText()
Returns the text value of this link.- Specified by:
getTextin interfaceHTMLElement- Overrides:
getTextin classWebRequestSource- Since:
- 1.6
-
asText
public java.lang.String asText()
Deprecated.as of 1.6, use #getText insteadReturns the text value of this link.
-
click
public WebResponse click() throws java.io.IOException, org.xml.sax.SAXException
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:
java.io.IOExceptionorg.xml.sax.SAXException
-
mouseOver
public void mouseOver()
Simulates moving the mouse over the link. Will fire the 'onMouseOver' event if defined.
-
newScriptable
public ScriptableDelegate newScriptable()
-
getRequest
public WebRequest getRequest()
Creates and returns a web request which will simulate clicking on this link.- Specified by:
getRequestin classWebRequestSource
-
getParameterNames
public java.lang.String[] getParameterNames()
Returns an array containing the names of any parameters defined as part of this link's URL.- Specified by:
getParameterNamesin classWebRequestSource
-
getParameterValues
public java.lang.String[] getParameterValues(java.lang.String name)
Returns the multiple default values of the named parameter.- Specified by:
getParameterValuesin classWebRequestSource
-
addPresetParameter
protected void addPresetParameter(java.lang.String name, java.lang.String value)Description copied from class:WebRequestSourceRecords 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:
addPresetParameterin classWebRequestSource
-
getEmptyParameterValue
protected java.lang.String getEmptyParameterValue()
- Specified by:
getEmptyParameterValuein classWebRequestSource
-
setDestination
protected void setDestination(java.lang.String destination)
- Overrides:
setDestinationin classWebRequestSource
-
recordParameters
public void recordParameters(com.meterware.httpunit.protocol.ParameterProcessor processor) throws java.io.IOExceptionIterates through the parameters in this holder, recording them in the supplied parameter processor.- Throws:
java.io.IOException
-
-