Package com.meterware.httpunit
Class WebRequestSource
java.lang.Object
com.meterware.httpunit.WebRequestSource
- All Implemented Interfaces:
HTMLElement
,com.meterware.httpunit.protocol.ParameterCollection
,ScriptingEventHandler
Base class for objects which can be clicked to generate new web requests.
- Author:
- Russell Gold
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
addPresetParameter
(String name, String value) Records a parameter defined by including it in the destination URL.boolean
Deprecated.since 1.7 - use doEventScript insteadboolean
doEventScript
(String eventScript) optional do the event if it's definedgetAttribute
(String name) get the attribute value for the given nameprotected final WebResponse
Returns the web response containing this request source.protected URL
Returns the class associated with this request source.protected WebResponse
protected String
Returns a copy of the domain object model subtree associated with this entity.protected Element
Returns the actual DOM for this request source, not a copy.protected abstract String
Returns the fragment identifier for this request source, used to identifier an element within an HTML document.getFrame()
Returns the frame containing this request source.protected HTMLPage
Returns the HTMLPage associated with this request source.getID()
Returns the ID associated with this request source.getName()
Returns the name associated with this request source.getNode()
Returns the DOM node underlying this element.Deprecated.as of 1.6, use #getFrameabstract String[]
Returns an array containing the names of any parameters to be sent on a request based on this request source.abstract String[]
getParameterValues
(String name) Returns the values of the named parameter.Returns the scriptable delegate which can provide the scriptable delegate for this element.protected String
get the relative URL for a weblink change spaces to %20abstract WebRequest
Creates and returns a web request from this request source.Returns the scriptable delegate.Returns the tag name of this node.Returns the target for this request source.getText()
Returns the text value of this block.getTitle()
Returns the title associated with this request source.boolean
handleEvent
(String eventName) handle the event with the given name by getting the attribute and then executing the eventScript for itboolean
isSupportedAttribute
(String name) Returns true if this element may have an attribute with the specified name.protected final void
Extracts any parameters specified as part of the destination URL, calling addPresetParameter for each one in the order in which they are found.void
removeAttribute
(String name) remove the given attributevoid
setAttribute
(String name, Object value) set the attribute with the given name to the given valueprotected void
setDestination
(String destination) protected void
setTargetAttribute
(String value) protected final WebResponse
submitRequest
(WebRequest request) Submits a request to the web client from which this request source was originally obtained.protected WebResponse
submitRequest
(String event, WebRequest request) submit the given event for the given requestMethods 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
Methods inherited from interface com.meterware.httpunit.protocol.ParameterCollection
recordParameters
-
Method Details
-
getID
Returns the ID associated with this request source.- Specified by:
getID
in interfaceHTMLElement
-
getClassName
Returns the class associated with this request source.- Specified by:
getClassName
in interfaceHTMLElement
-
getName
Returns the name associated with this request source.- Specified by:
getName
in interfaceHTMLElement
-
getTitle
Returns the title associated with this request source.- Specified by:
getTitle
in interfaceHTMLElement
-
getTarget
Returns the target for this request source. -
getPageFrame
Deprecated.as of 1.6, use #getFrameReturns the name of the frame containing this request source. -
getFrame
Returns the frame containing this request source. -
getFragmentIdentifier
Returns the fragment identifier for this request source, used to identifier an element within an HTML document. -
getDOMSubtree
Returns a copy of the domain object model subtree associated with this entity. -
getRequest
Creates and returns a web request from this request source. -
getParameterNames
Returns an array containing the names of any parameters to be sent on a request based on this request source. -
getParameterValues
Returns the values of the named parameter. -
getRelativeURL
get the relative URL for a weblink change spaces to %20- Returns:
- the relative URL as a string
-
getBaseURL
-
getDestination
-
setDestination
-
getElement
Returns the actual DOM for this request source, not a copy. -
getHTMLPage
Returns the HTMLPage associated with this request source.- Throws:
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(String event, WebRequest request) throws IOException, SAXException submit the given event for the given request- Parameters:
event
-request
-- Returns:
- the response for the submitted Request
- Throws:
IOException
SAXException
-
doEvent
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:
doEvent
in interfaceScriptingEventHandler
- Parameters:
eventScript
- - the script to use- Returns:
- true if the script is empty or the result of the script
-
doEventScript
optional do the event if it's defined- Specified by:
doEventScript
in interfaceScriptingEventHandler
- Parameters:
eventScript
- - the script to handle- Returns:
- whether the script was handled
-
handleEvent
Description copied from interface:ScriptingEventHandler
handle the event with the given name by getting the attribute and then executing the eventScript for it- Specified by:
handleEvent
in interfaceScriptingEventHandler
- Returns:
- the result of doEventScript
-
getCurrentFrameContents
-
submitRequest
Submits a request to the web client from which this request source was originally obtained.- Throws:
IOException
SAXException
-
getBaseResponse
Returns the web response containing this request source. -
addPresetParameter
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
get the attribute value for the given name- Specified by:
getAttribute
in interfaceHTMLElement
- Parameters:
name
- - the name of the attribute to get
-
setAttribute
set the attribute with the given name to the given value- Specified by:
setAttribute
in interfaceHTMLElement
- Parameters:
name
- - the name of the attributevalue
- - the value to use
-
removeAttribute
remove the given attribute- Specified by:
removeAttribute
in interfaceHTMLElement
- Parameters:
name
- - the name of the attribute to remove
-
isSupportedAttribute
Description copied from interface:HTMLElement
Returns true if this element may have an attribute with the specified name.- Specified by:
isSupportedAttribute
in interfaceHTMLElement
-
getNode
Description copied from interface:HTMLElement
Returns the DOM node underlying this element.- Specified by:
getNode
in interfaceHTMLElement
-
getText
Returns the text value of this block.- Specified by:
getText
in interfaceHTMLElement
-
getTagName
Description copied from interface:HTMLElement
Returns the tag name of this node.- Specified by:
getTagName
in interfaceHTMLElement
-
setTargetAttribute
-
getEmptyParameterValue
-
getScriptingHandler
Returns the scriptable delegate.- Specified by:
getScriptingHandler
in interfaceHTMLElement
-
getParentDelegate
Description copied from interface:HTMLElement
Returns the scriptable delegate which can provide the scriptable delegate for this element.- Specified by:
getParentDelegate
in interfaceHTMLElement
-