|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.meterware.httpunit.WebClient
The context for a series of web requests. This class manages cookies used to maintain session context, computes relative URLs, and generally emulates the browser behavior needed to build an automated test of a web site.
Nested Class Summary | |
static class |
WebClient.HeaderDictionary
|
Constructor Summary | |
protected |
WebClient()
|
Method Summary | |
void |
addClientListener(WebClientListener listener)
Adds a listener to watch for requests and responses. |
void |
addCookie(java.lang.String name,
java.lang.String value)
Defines a cookie to be sent to the server on every request. |
void |
addWindowListener(WebWindowListener listener)
Adds a listener to watch for window openings and closings. |
void |
clearContents()
Resets the state of this client, removing all cookies, frames, and per-client headers. |
void |
clearProxyServer()
Clears the proxy server settings. |
ClientProperties |
getClientProperties()
Returns the properties associated with this client. |
java.lang.String[] |
getCookieNames()
Returns the name of all the active cookies which will be sent to the server. |
java.lang.String |
getCookieValue(java.lang.String name)
Returns the value of the specified cookie. |
WebResponse |
getCurrentPage()
Returns the response representing the current top page in the main window. |
boolean |
getExceptionsThrownOnErrorStatus()
Returns true if an exception will be thrown when an error status (4xx or 5xx) is detected on a response. |
WebResponse |
getFrameContents(java.lang.String frameName)
Returns the response associated with the specified frame name in the main window. |
java.lang.String[] |
getFrameNames()
Returns the name of the currently active frames in the main window. |
java.lang.String |
getHeaderField(java.lang.String fieldName)
Returns the value for the header field with the specified name. |
protected java.util.Dictionary |
getHeaderFields(java.net.URL targetURL)
Returns the value of all current header fields. |
WebWindow |
getMainWindow()
|
java.lang.String |
getNextAlert()
Returns the next javascript alert without removing it from the queue. |
WebWindow |
getOpenWindow(java.lang.String name)
|
WebWindow[] |
getOpenWindows()
|
java.lang.String |
getProxyHost()
Returns the name of the active proxy server. |
int |
getProxyPort()
Returns the number of the active proxy port, or 0 is none is specified. |
WebResponse |
getResource(WebRequest request)
Returns the resource specified by the request. |
WebResponse |
getResponse(java.lang.String urlString)
Submits a GET method request and returns a response. |
WebResponse |
getResponse(WebRequest request)
Submits a web request and returns a response, using all state developed so far as stored in cookies as requested by the server. |
protected java.lang.String |
getTargetFrame(WebRequest request)
|
java.lang.String |
getUserAgent()
Deprecated. as of 1.4.6. Use ClientProperties#getUserAgent instead. |
protected abstract WebResponse |
newResponse(WebRequest request,
java.lang.String frameName)
Creates a web response object which represents the response to the specified web request. |
java.lang.String |
popNextAlert()
Returns the next javascript alert and removes it from the queue. |
void |
removeClientListener(WebClientListener listener)
Removes a listener to watch for requests and responses. |
void |
removeWindowListener(WebWindowListener listener)
Removes a listener to watch for window openings and closings. |
WebResponse |
sendRequest(WebRequest request)
Submits a web request and returns a response. |
void |
setAuthorization(java.lang.String userName,
java.lang.String password)
Sets a username and password for a basic authentication scheme. |
void |
setDialogResponder(DialogResponder responder)
Specifies the object which will respond to all dialogs. |
void |
setExceptionsThrownOnErrorStatus(boolean throwExceptions)
Specifies whether an exception will be thrown when an error status (4xx or 5xx) is detected on a response. |
void |
setHeaderField(java.lang.String fieldName,
java.lang.String fieldValue)
Sets the value for a header field to be sent with all requests. |
void |
setMainWindow(WebWindow mainWindow)
|
void |
setProxyServer(java.lang.String proxyHost,
int proxyPort)
Specifies a proxy server to use. |
void |
setUserAgent(java.lang.String userAgent)
Deprecated. as of 1.4.6. Use ClientProperties#setUserAgent instead. |
protected void |
updateMainWindow(java.lang.String target,
WebResponse response)
Updates this web client based on a received response. |
protected void |
writeMessageBody(WebRequest request,
java.io.OutputStream stream)
Writes the message body for the request. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected WebClient()
Method Detail |
public WebWindow getMainWindow()
public void setMainWindow(WebWindow mainWindow)
public WebWindow[] getOpenWindows()
public WebWindow getOpenWindow(java.lang.String name)
public WebResponse getResponse(java.lang.String urlString) throws java.net.MalformedURLException, java.io.IOException, org.xml.sax.SAXException
org.xml.sax.SAXException
- thrown if there is an error parsing the retrieved page
java.net.MalformedURLException
java.io.IOException
public WebResponse sendRequest(WebRequest request) throws java.net.MalformedURLException, java.io.IOException, org.xml.sax.SAXException
java.net.MalformedURLException
java.io.IOException
org.xml.sax.SAXException
public WebResponse getCurrentPage()
public WebResponse getResponse(WebRequest request) throws java.net.MalformedURLException, java.io.IOException, org.xml.sax.SAXException
org.xml.sax.SAXException
- thrown if there is an error parsing the retrieved page
java.net.MalformedURLException
java.io.IOException
public java.lang.String[] getFrameNames()
public WebResponse getFrameContents(java.lang.String frameName)
public WebResponse getResource(WebRequest request) throws java.io.IOException
java.io.IOException
public void clearContents()
public void addCookie(java.lang.String name, java.lang.String value)
public java.lang.String[] getCookieNames()
public java.lang.String getCookieValue(java.lang.String name)
public ClientProperties getClientProperties()
public void setUserAgent(java.lang.String userAgent)
public java.lang.String getUserAgent()
public void setAuthorization(java.lang.String userName, java.lang.String password)
public void setProxyServer(java.lang.String proxyHost, int proxyPort)
public void clearProxyServer()
public java.lang.String getProxyHost()
public int getProxyPort()
public void setHeaderField(java.lang.String fieldName, java.lang.String fieldValue)
public java.lang.String getHeaderField(java.lang.String fieldName)
public void setExceptionsThrownOnErrorStatus(boolean throwExceptions)
public boolean getExceptionsThrownOnErrorStatus()
public void addClientListener(WebClientListener listener)
public void removeClientListener(WebClientListener listener)
public void addWindowListener(WebWindowListener listener)
public void removeWindowListener(WebWindowListener listener)
public java.lang.String getNextAlert()
public java.lang.String popNextAlert()
public void setDialogResponder(DialogResponder responder)
protected abstract WebResponse newResponse(WebRequest request, java.lang.String frameName) throws java.net.MalformedURLException, java.io.IOException
java.net.MalformedURLException
java.io.IOException
protected final void writeMessageBody(WebRequest request, java.io.OutputStream stream) throws java.io.IOException
java.io.IOException
protected java.util.Dictionary getHeaderFields(java.net.URL targetURL)
protected final void updateMainWindow(java.lang.String target, WebResponse response) throws java.net.MalformedURLException, java.io.IOException, org.xml.sax.SAXException
java.net.MalformedURLException
java.io.IOException
org.xml.sax.SAXException
protected final java.lang.String getTargetFrame(WebRequest request)
|
Copyright © 2000-2003 Russell Gold. See license agreement for rights granted. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |