Package com.meterware.httpunit
Class WebRequestSource
- java.lang.Object
-
- com.meterware.httpunit.WebRequestSource
-
- All Implemented Interfaces:
HTMLElement,com.meterware.httpunit.protocol.ParameterCollection,ScriptingEventHandler
public abstract class WebRequestSource extends java.lang.Object implements HTMLElement
Base class for objects which can be clicked to generate new web requests.- Author:
- Russell Gold
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract voidaddPresetParameter(java.lang.String name, java.lang.String value)Records a parameter defined by including it in the destination URL.booleandoEvent(java.lang.String eventScript)Deprecated.since 1.7 - use doEventScript insteadbooleandoEventScript(java.lang.String eventScript)optional do the event if it's definedjava.lang.StringgetAttribute(java.lang.String name)get the attribute value for the given nameprotected WebResponsegetBaseResponse()Returns the web response containing this request source.protected java.net.URLgetBaseURL()java.lang.StringgetClassName()Returns the class associated with this request source.protected WebResponsegetCurrentFrameContents()protected java.lang.StringgetDestination()org.w3c.dom.NodegetDOMSubtree()Returns a copy of the domain object model subtree associated with this entity.protected org.w3c.dom.ElementgetElement()Returns the actual DOM for this request source, not a copy.protected abstract java.lang.StringgetEmptyParameterValue()java.lang.StringgetFragmentIdentifier()Returns the fragment identifier for this request source, used to identifier an element within an HTML document.FrameSelectorgetFrame()Returns the frame containing this request source.protected HTMLPagegetHTMLPage()Returns the HTMLPage associated with this request source.java.lang.StringgetID()Returns the ID associated with this request source.java.lang.StringgetName()Returns the name associated with this request source.org.w3c.dom.NodegetNode()Returns the DOM node underlying this element.java.lang.StringgetPageFrame()Deprecated.as of 1.6, use #getFrameabstract java.lang.String[]getParameterNames()Returns an array containing the names of any parameters to be sent on a request based on this request source.abstract java.lang.String[]getParameterValues(java.lang.String name)Returns the values of the named parameter.ScriptableDelegategetParentDelegate()Returns the scriptable delegate which can provide the scriptable delegate for this element.protected java.lang.StringgetRelativeURL()get the relative URL for a weblink change spaces to %20abstract WebRequestgetRequest()Creates and returns a web request from this request source.ScriptingHandlergetScriptingHandler()Returns the scriptable delegate.java.lang.StringgetTagName()Returns the tag name of this node.java.lang.StringgetTarget()Returns the target for this request source.java.lang.StringgetText()Returns the text value of this block.java.lang.StringgetTitle()Returns the title associated with this request source.booleanhandleEvent(java.lang.String eventName)handle the event with the given name by getting the attribute and then executing the eventScript for itbooleanisSupportedAttribute(java.lang.String name)Returns true if this element may have an attribute with the specified name.protected voidloadDestinationParameters()Extracts any parameters specified as part of the destination URL, calling addPresetParameter for each one in the order in which they are found.voidremoveAttribute(java.lang.String name)remove the given attributevoidsetAttribute(java.lang.String name, java.lang.Object value)set the attribute with the given name to the given valueprotected voidsetDestination(java.lang.String destination)protected voidsetTargetAttribute(java.lang.String value)protected WebResponsesubmitRequest(WebRequest request)Submits a request to the web client from which this request source was originally obtained.protected WebResponsesubmitRequest(java.lang.String event, WebRequest request)submit the given event for the given request-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.meterware.httpunit.HTMLElement
newScriptable
-
-
-
-
Method Detail
-
getID
public java.lang.String getID()
Returns the ID associated with this request source.- Specified by:
getIDin interfaceHTMLElement
-
getClassName
public java.lang.String getClassName()
Returns the class associated with this request source.- Specified by:
getClassNamein interfaceHTMLElement
-
getName
public java.lang.String getName()
Returns the name associated with this request source.- Specified by:
getNamein interfaceHTMLElement
-
getTitle
public java.lang.String getTitle()
Returns the title associated with this request source.- Specified by:
getTitlein interfaceHTMLElement
-
getTarget
public java.lang.String getTarget()
Returns the target for this request source.
-
getPageFrame
public java.lang.String getPageFrame()
Deprecated.as of 1.6, use #getFrameReturns the name of the frame containing this request source.
-
getFrame
public FrameSelector getFrame()
Returns the frame containing this request source.
-
getFragmentIdentifier
public java.lang.String getFragmentIdentifier()
Returns the fragment identifier for this request source, used to identifier an element within an HTML document.
-
getDOMSubtree
public org.w3c.dom.Node getDOMSubtree()
Returns a copy of the domain object model subtree associated with this entity.
-
getRequest
public abstract WebRequest getRequest()
Creates and returns a web request from this request source.
-
getParameterNames
public abstract java.lang.String[] getParameterNames()
Returns an array containing the names of any parameters to be sent on a request based on this request source.
-
getParameterValues
public abstract java.lang.String[] getParameterValues(java.lang.String name)
Returns the values of the named parameter.
-
getRelativeURL
protected java.lang.String getRelativeURL()
get the relative URL for a weblink change spaces to %20- Returns:
- the relative URL as a string
-
getBaseURL
protected java.net.URL getBaseURL()
-
getDestination
protected java.lang.String getDestination()
-
setDestination
protected void setDestination(java.lang.String destination)
-
getElement
protected org.w3c.dom.Element getElement()
Returns the actual DOM for this request source, not a copy.
-
getHTMLPage
protected HTMLPage getHTMLPage() throws org.xml.sax.SAXException
Returns the HTMLPage associated with this request source.- Throws:
org.xml.sax.SAXException
-
loadDestinationParameters
protected final void loadDestinationParameters()
Extracts any parameters specified as part of the destination URL, calling addPresetParameter for each one in the order in which they are found.
-
submitRequest
protected WebResponse submitRequest(java.lang.String event, WebRequest request) throws java.io.IOException, org.xml.sax.SAXException
submit the given event for the given request- Parameters:
event-request-- Returns:
- the response for the submitted Request
- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
doEvent
public boolean doEvent(java.lang.String eventScript)
Deprecated.since 1.7 - use doEventScript insteadhandle the event that has the given script attached by compiling the eventScript as a function and executing it- Specified by:
doEventin interfaceScriptingEventHandler- Parameters:
eventScript- - the script to use- Returns:
- true if the script is empty or the result of the script
-
doEventScript
public boolean doEventScript(java.lang.String eventScript)
optional do the event if it's defined- Specified by:
doEventScriptin interfaceScriptingEventHandler- Parameters:
eventScript- - the script to handle- Returns:
- whether the script was handled
-
handleEvent
public boolean handleEvent(java.lang.String eventName)
Description copied from interface:ScriptingEventHandlerhandle the event with the given name by getting the attribute and then executing the eventScript for it- Specified by:
handleEventin interfaceScriptingEventHandler- Returns:
- the result of doEventScript
-
getCurrentFrameContents
protected WebResponse getCurrentFrameContents()
-
submitRequest
protected final WebResponse submitRequest(WebRequest request) throws java.io.IOException, org.xml.sax.SAXException
Submits a request to the web client from which this request source was originally obtained.- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
getBaseResponse
protected final WebResponse getBaseResponse()
Returns the web response containing this request source.
-
addPresetParameter
protected abstract void addPresetParameter(java.lang.String name, java.lang.String value)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.
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
get the attribute value for the given name- Specified by:
getAttributein interfaceHTMLElement- Parameters:
name- - the name of the attribute to get
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)set the attribute with the given name to the given value- Specified by:
setAttributein interfaceHTMLElement- Parameters:
name- - the name of the attributevalue- - the value to use
-
removeAttribute
public void removeAttribute(java.lang.String name)
remove the given attribute- Specified by:
removeAttributein interfaceHTMLElement- Parameters:
name- - the name of the attribute to remove
-
isSupportedAttribute
public boolean isSupportedAttribute(java.lang.String name)
Description copied from interface:HTMLElementReturns true if this element may have an attribute with the specified name.- Specified by:
isSupportedAttributein interfaceHTMLElement
-
getNode
public org.w3c.dom.Node getNode()
Description copied from interface:HTMLElementReturns the DOM node underlying this element.- Specified by:
getNodein interfaceHTMLElement
-
getText
public java.lang.String getText()
Returns the text value of this block.- Specified by:
getTextin interfaceHTMLElement
-
getTagName
public java.lang.String getTagName()
Description copied from interface:HTMLElementReturns the tag name of this node.- Specified by:
getTagNamein interfaceHTMLElement
-
setTargetAttribute
protected void setTargetAttribute(java.lang.String value)
-
getEmptyParameterValue
protected abstract java.lang.String getEmptyParameterValue()
-
getScriptingHandler
public ScriptingHandler getScriptingHandler()
Returns the scriptable delegate.- Specified by:
getScriptingHandlerin interfaceHTMLElement
-
getParentDelegate
public ScriptableDelegate getParentDelegate()
Description copied from interface:HTMLElementReturns the scriptable delegate which can provide the scriptable delegate for this element.- Specified by:
getParentDelegatein interfaceHTMLElement
-
-