Class WebRequestSource

java.lang.Object
com.meterware.httpunit.WebRequestSource
All Implemented Interfaces:
HTMLElement, com.meterware.httpunit.protocol.ParameterCollection, ScriptingEventHandler
Direct Known Subclasses:
WebForm, WebImage, WebLink

public abstract class WebRequestSource extends Object implements HTMLElement
Base class for objects which can be clicked to generate new web requests.
Author:
Russell Gold
  • Method Details

    • getID

      public String getID()
      Returns the ID associated with this request source.
      Specified by:
      getID in interface HTMLElement
    • getClassName

      public String getClassName()
      Returns the class associated with this request source.
      Specified by:
      getClassName in interface HTMLElement
    • getName

      public String getName()
      Returns the name associated with this request source.
      Specified by:
      getName in interface HTMLElement
    • getTitle

      public String getTitle()
      Returns the title associated with this request source.
      Specified by:
      getTitle in interface HTMLElement
    • getTarget

      public String getTarget()
      Returns the target for this request source.
    • getPageFrame

      public String getPageFrame()
      Deprecated.
      as of 1.6, use #getFrame
      Returns the name of the frame containing this request source.
    • getFrame

      public FrameSelector getFrame()
      Returns the frame containing this request source.
    • getFragmentIdentifier

      public String getFragmentIdentifier()
      Returns the fragment identifier for this request source, used to identifier an element within an HTML document.
    • getDOMSubtree

      public 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 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 String[] getParameterValues(String name)
      Returns the values of the named parameter.
    • getRelativeURL

      protected String getRelativeURL()
      get the relative URL for a weblink change spaces to %20
      Returns:
      the relative URL as a string
    • getBaseURL

      protected URL getBaseURL()
    • getDestination

      protected String getDestination()
    • setDestination

      protected void setDestination(String destination)
    • getElement

      protected Element getElement()
      Returns the actual DOM for this request source, not a copy.
    • getHTMLPage

      protected HTMLPage getHTMLPage() throws SAXException
      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

      public boolean doEvent(String eventScript)
      Deprecated.
      since 1.7 - use doEventScript instead
      handle the event that has the given script attached by compiling the eventScript as a function and executing it
      Specified by:
      doEvent in interface ScriptingEventHandler
      Parameters:
      eventScript - - the script to use
      Returns:
      true if the script is empty or the result of the script
    • doEventScript

      public boolean doEventScript(String eventScript)
      optional do the event if it's defined
      Specified by:
      doEventScript in interface ScriptingEventHandler
      Parameters:
      eventScript - - the script to handle
      Returns:
      whether the script was handled
    • handleEvent

      public boolean handleEvent(String eventName)
      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 interface ScriptingEventHandler
      Parameters:
      eventName -
      Returns:
      the result of doEventScript
    • getCurrentFrameContents

      protected WebResponse getCurrentFrameContents()
    • submitRequest

      protected final WebResponse submitRequest(WebRequest request) throws IOException, SAXException
      Submits a request to the web client from which this request source was originally obtained.
      Throws:
      IOException
      SAXException
    • getBaseResponse

      protected final WebResponse getBaseResponse()
      Returns the web response containing this request source.
    • addPresetParameter

      protected abstract void addPresetParameter(String name, 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 String getAttribute(String name)
      get the attribute value for the given name
      Specified by:
      getAttribute in interface HTMLElement
      Parameters:
      name - - the name of the attribute to get
    • setAttribute

      public void setAttribute(String name, Object value)
      set the attribute with the given name to the given value
      Specified by:
      setAttribute in interface HTMLElement
      Parameters:
      name - - the name of the attribute
      value - - the value to use
    • removeAttribute

      public void removeAttribute(String name)
      remove the given attribute
      Specified by:
      removeAttribute in interface HTMLElement
      Parameters:
      name - - the name of the attribute to remove
    • isSupportedAttribute

      public boolean isSupportedAttribute(String name)
      Description copied from interface: HTMLElement
      Returns true if this element may have an attribute with the specified name.
      Specified by:
      isSupportedAttribute in interface HTMLElement
    • getNode

      public Node getNode()
      Description copied from interface: HTMLElement
      Returns the DOM node underlying this element.
      Specified by:
      getNode in interface HTMLElement
    • getText

      public String getText()
      Returns the text value of this block.
      Specified by:
      getText in interface HTMLElement
    • getTagName

      public String getTagName()
      Description copied from interface: HTMLElement
      Returns the tag name of this node.
      Specified by:
      getTagName in interface HTMLElement
    • setTargetAttribute

      protected void setTargetAttribute(String value)
    • getEmptyParameterValue

      protected abstract String getEmptyParameterValue()
    • getScriptingHandler

      public ScriptingHandler getScriptingHandler()
      Returns the scriptable delegate.
      Specified by:
      getScriptingHandler in interface HTMLElement
    • getParentDelegate

      public ScriptableDelegate getParentDelegate()
      Description copied from interface: HTMLElement
      Returns the scriptable delegate which can provide the scriptable delegate for this element.
      Specified by:
      getParentDelegate in interface HTMLElement