|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gargoylesoftware.htmlunit.WebClient
public class WebClient
The main starting point in HtmlUnit: this class simulates a web browser.
A standard usage of HtmlUnit will start with using the getPage(String)
method
(or getPage(URL)
) to load a first Page
and will continue with further processing on this page depending on its type.
final WebClient webClient = new WebClient();
final HtmlPage
startPage = webClient.getPage("http://htmlunit.sf.net");
assertEquals("HtmlUnit - Welcome to HtmlUnit", startPage.getTitleText
());
Note: a WebClient
instance is not thread safe. It is intended to be used from a single thread.
Field Summary | |
---|---|
static URL |
URL_ABOUT_BLANK
URL for "about:blank". |
Constructor Summary | |
---|---|
WebClient()
Creates a web client instance using the browser version returned by BrowserVersion.getDefault() . |
|
WebClient(BrowserVersion browserVersion)
Creates a web client instance using the specified BrowserVersion . |
|
WebClient(BrowserVersion browserVersion,
String proxyHost,
int proxyPort)
Creates an instance that will use the specified BrowserVersion and proxy server. |
Method Summary | ||
---|---|---|
void |
addRequestHeader(String name,
String value)
Adds a header which will be sent with EVERY request from this client. |
|
void |
addWebWindowListener(WebWindowListener listener)
Adds a listener for WebWindowEvent s. |
|
void |
closeAllWindows()
Closes all opened windows, stopping all background JavaScript processing. |
|
void |
deregisterWebWindow(WebWindow webWindow)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Removes a window from the list of available windows. |
|
void |
download(WebWindow requestingWindow,
String target,
WebRequest request,
String description)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Perform the downloads and stores it for loading later into a window. |
|
static URL |
expandUrl(URL baseUrl,
String relativeUrl)
Expands a relative URL relative to the specified base. |
|
Map<String,String> |
getActiveXObjectMap()
Returns the active X object map for this webclient. |
|
AjaxController |
getAjaxController()
Gets the current AJAX controller. |
|
AlertHandler |
getAlertHandler()
Returns the alert handler for this webclient. |
|
AttachmentHandler |
getAttachmentHandler()
Returns the current attachment handler. |
|
BrowserVersion |
getBrowserVersion()
Returns the current browser version. |
|
Cache |
getCache()
Gets the cache currently being used. |
|
ConfirmHandler |
getConfirmHandler()
Returns the confirm handler. |
|
CookieManager |
getCookieManager()
Returns the cookie manager used by this web client. |
|
CredentialsProvider |
getCredentialsProvider()
Returns the credentials provider for this client instance. |
|
org.w3c.css.sac.ErrorHandler |
getCssErrorHandler()
Returns the CSS error handler used by this web client when CSS problems are encountered. |
|
WebWindow |
getCurrentWindow()
Returns the "current" window for this client. |
|
String |
getHomePage()
Returns the client's current homepage. |
|
HTMLParserListener |
getHTMLParserListener()
Gets the configured listener for messages generated by the HTML parser. |
|
IncorrectnessListener |
getIncorrectnessListener()
Gets the current listener for encountered incorrectness (except HTML parsing messages that are handled by the HTML parser listener). |
|
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine |
getJavaScriptEngine()
This method is intended for testing only - use at your own risk. |
|
long |
getJavaScriptTimeout()
Returns the number of milliseconds that a script is allowed to execute before being terminated. |
|
OnbeforeunloadHandler |
getOnbeforeunloadHandler()
Returns the onbeforeunload handler for this webclient. |
|
|
getPage(String url)
Convenient method to build an URL and load it into the current WebWindow as it would be done by getPage(WebWindow, WebRequest) . |
|
|
getPage(URL url)
Convenient method to load a URL into the current top WebWindow as it would be done by getPage(WebWindow, WebRequest) . |
|
|
getPage(WebRequest request)
Convenient method to load a web request into the current top WebWindow. |
|
|
getPage(WebWindow opener,
String target,
WebRequest params)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. |
|
|
getPage(WebWindow webWindow,
WebRequest parameters)
Send a request to a server and return a Page that represents the response from the server. |
|
PageCreator |
getPageCreator()
Returns the current page creator. |
|
boolean |
getPrintContentOnFailingStatusCode()
Returns true if the content of the resulting document will be printed to the console in the event of a failing response code. |
|
PromptHandler |
getPromptHandler()
Returns the prompt handler. |
|
ProxyConfig |
getProxyConfig()
Returns the proxy configuration for this client. |
|
RefreshHandler |
getRefreshHandler()
Returns the current refresh handler or null if one has not been set. |
|
ScriptPreProcessor |
getScriptPreProcessor()
Returns the script pre processor for this webclient. |
|
StatusHandler |
getStatusHandler()
Returns the status handler for this webclient. |
|
int |
getTimeout()
Gets the timeout value for the WebConnection . |
|
List<TopLevelWindow> |
getTopLevelWindows()
Returns an immutable list of open top level windows. |
|
WebConnection |
getWebConnection()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. |
|
WebWindow |
getWebWindowByName(String name)
Returns the first WebWindow that matches the specified name. |
|
List<WebWindow> |
getWebWindows()
Returns an immutable list of open web windows (whether they are top level windows or not). |
|
String |
guessContentType(File file)
Tries to guess the content type of the file. This utility could be located in an helper class but we can compare this functionality for instance with the "Helper Applications" settings of Mozilla and therefore see it as a property of the "browser". |
|
void |
initialize(Page newPage)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Initializes a new page for JavaScript. |
|
void |
initialize(WebWindow webWindow)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Initializes a new web window for JavaScript. |
|
void |
initializeEmptyWindow(WebWindow webWindow)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Initializes a new empty window for JavaScript. |
|
boolean |
isActiveXNative()
Returns whether native ActiveX components are allowed or no. |
|
boolean |
isAppletEnabled()
Returns true if Applet are enabled. |
|
boolean |
isCssEnabled()
Returns true if CSS is enabled. |
|
boolean |
isJavaScriptEnabled()
Returns true if JavaScript is enabled and the script engine was loaded successfully. |
|
boolean |
isPopupBlockerEnabled()
Returns true if the popup window blocker is enabled. |
|
boolean |
isRedirectEnabled()
Returns whether or not redirections will be followed automatically on receipt of a redirect status code from the server. |
|
boolean |
isThrowExceptionOnFailingStatusCode()
Returns true if an exception will be thrown in the event of a failing response code. |
|
boolean |
isThrowExceptionOnScriptError()
Indicates if an exception should be thrown when a script execution fails (the default) or if it should be caught and just logged to allow page execution to continue. |
|
void |
loadDownloadedResponses()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Loads downloaded responses into the corresponding windows. |
|
WebResponse |
loadWebResponse(WebRequest webRequest)
Loads a WebResponse from the server. |
|
Page |
loadWebResponseInto(WebResponse webResponse,
WebWindow webWindow)
Creates a page based on the specified response and inserts it into the specified window. |
|
DialogWindow |
openDialogWindow(URL url,
WebWindow opener,
Object dialogArguments)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. |
|
WebWindow |
openWindow(URL url,
String windowName)
Open a new window with the specified name. |
|
WebWindow |
openWindow(URL url,
String windowName,
WebWindow opener)
Open a new window with the specified name. |
|
void |
printContentIfNecessary(WebResponse webResponse)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. |
|
void |
registerWebWindow(WebWindow webWindow)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Adds a new window to the list of available windows. |
|
void |
removeRequestHeader(String name)
Removes a header from being sent with EVERY request from this client. |
|
void |
removeWebWindowListener(WebWindowListener listener)
Removes a listener for WebWindowEvent s. |
|
void |
setActiveXNative(boolean allow)
Sets whether to allow native ActiveX or no. |
|
void |
setActiveXObjectMap(Map<String,String> activeXObjectMap)
Sets the active X object map for this webclient. |
|
void |
setAjaxController(AjaxController newValue)
Sets the current AJAX controller. |
|
void |
setAlertHandler(AlertHandler alertHandler)
Sets the alert handler for this webclient. |
|
void |
setAppletEnabled(boolean enabled)
Enables/disables Applet support. |
|
void |
setAttachmentHandler(AttachmentHandler handler)
Sets the attachment handler. |
|
void |
setCache(Cache cache)
Sets the cache to use. |
|
void |
setConfirmHandler(ConfirmHandler handler)
Sets the handler that will be executed when the JavaScript method Window.confirm() is called. |
|
void |
setCookieManager(CookieManager cookieManager)
Sets the cookie manager used by this web client. |
|
void |
setCredentialsProvider(CredentialsProvider credentialsProvider)
Sets the credentials provider that will provide authentication information when trying to access protected information on a web server. |
|
void |
setCssEnabled(boolean enabled)
Enables/disables CSS support. |
|
void |
setCssErrorHandler(org.w3c.css.sac.ErrorHandler cssErrorHandler)
Sets the CSS error handler used by this web client when CSS problems are encountered. |
|
void |
setCurrentWindow(WebWindow window)
Sets the "current" window for this client. |
|
void |
setHomePage(String homePage)
Sets the client's homepage. |
|
void |
setHTMLParserListener(HTMLParserListener listener)
Sets the listener for messages generated by the HTML parser. |
|
void |
setIncorrectnessListener(IncorrectnessListener listener)
Returns the current HTML incorrectness listener. |
|
void |
setJavaScriptEnabled(boolean enabled)
Enables/disables JavaScript support. |
|
void |
setJavaScriptEngine(com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine engine)
This method is intended for testing only - use at your own risk. |
|
void |
setJavaScriptTimeout(long timeout)
Sets the number of milliseconds that a script is allowed to execute before being terminated. |
|
void |
setOnbeforeunloadHandler(OnbeforeunloadHandler onbeforeunloadHandler)
Sets the onbeforeunload handler for this webclient. |
|
void |
setPageCreator(PageCreator pageCreator)
Sets the object that will be used to create pages. |
|
void |
setPopupBlockerEnabled(boolean enabled)
Enable/disable the popup window blocker. |
|
void |
setPrintContentOnFailingStatusCode(boolean enabled)
Specify whether or not the content of the resulting document will be printed to the console in the event of a failing response code. |
|
void |
setPromptHandler(PromptHandler handler)
Sets the handler that will be executed when the JavaScript method Window.prompt() is called. |
|
void |
setProxyConfig(ProxyConfig proxyConfig)
Sets the proxy configuration for this client. |
|
void |
setRedirectEnabled(boolean enabled)
Sets whether or not redirections will be followed automatically on receipt of a redirect status code from the server. |
|
void |
setRefreshHandler(RefreshHandler handler)
Sets the handler to be used whenever a refresh is triggered. |
|
void |
setScriptPreProcessor(ScriptPreProcessor scriptPreProcessor)
Sets the script pre processor for this webclient. |
|
void |
setStatusHandler(StatusHandler statusHandler)
Sets the status handler for this webclient. |
|
void |
setThrowExceptionOnFailingStatusCode(boolean enabled)
Specify whether or not an exception will be thrown in the event of a failing status code. |
|
void |
setThrowExceptionOnScriptError(boolean newValue)
Changes the behavior of this webclient when a script error occurs. |
|
void |
setTimeout(int timeout)
Sets the timeout of the WebConnection . |
|
void |
setUseInsecureSSL(boolean useInsecureSSL)
If set to true, the client will accept connections to any host, regardless of whether they have valid certificates or not. |
|
void |
setWebConnection(WebConnection webConnection)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. Sets the object that will resolve all URL requests. |
|
void |
throwFailingHttpStatusCodeExceptionIfNecessary(WebResponse webResponse)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK. |
|
int |
waitForBackgroundJavaScript(long timeoutMillis)
Experimental API: May be changed in next release and may not yet work perfectly! |
|
int |
waitForBackgroundJavaScriptStartingBefore(long delayMillis)
Experimental API: May be changed in next release and may not yet work perfectly! |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final URL URL_ABOUT_BLANK
Constructor Detail |
---|
public WebClient()
BrowserVersion.getDefault()
.
public WebClient(BrowserVersion browserVersion)
BrowserVersion
.
browserVersion
- the browser version to simulatepublic WebClient(BrowserVersion browserVersion, String proxyHost, int proxyPort)
BrowserVersion
and proxy server.
browserVersion
- the browser version to simulateproxyHost
- the server that will act as proxyproxyPort
- the port to use on the proxy serverMethod Detail |
---|
public WebConnection getWebConnection()
Return the object that will resolve all URL requests
public void setWebConnection(WebConnection webConnection)
webConnection
- the new web connectionpublic <P extends Page> P getPage(WebWindow webWindow, WebRequest parameters) throws IOException, FailingHttpStatusCodeException
The returned Page
will be created by the PageCreator
configured by setPageCreator(PageCreator)
, if any.
The DefaultPageCreator
will create a Page
depending on the content type of the HTTP response,
basically HtmlPage
for HTML content, XmlPage
for XML content,
TextPage
for other text content and UnexpectedPage
for anything else.
P
- the page typewebWindow
- the WebWindow to load the result of the request intoparameters
- Parameter object for the web request
IOException
- if an IO error occurs
FailingHttpStatusCodeException
- if the server returns a failing status code AND the property
setThrowExceptionOnFailingStatusCode(boolean)
is set to trueWebRequest
public <P extends Page> P getPage(WebWindow opener, String target, WebRequest params) throws FailingHttpStatusCodeException, IOException
Open a new web window and populate it with a page loaded by
getPage(WebWindow,WebRequest)
P
- the page typeopener
- the web window that initiated the requesttarget
- the name of the window to be opened (the name that will be passed into the
JavaScript open() method)params
- any parameters
FailingHttpStatusCodeException
- if the server returns a failing status code AND the property
setThrowExceptionOnFailingStatusCode(boolean)
is set to true.
IOException
- if an IO problem occurspublic <P extends Page> P getPage(String url) throws IOException, FailingHttpStatusCodeException, MalformedURLException
getPage(WebWindow, WebRequest)
.
P
- the page typeurl
- the URL of the new content
FailingHttpStatusCodeException
- if the server returns a failing status code AND the property
setThrowExceptionOnFailingStatusCode(boolean)
is set to true.
IOException
- if an IO problem occurs
MalformedURLException
- if no URL can be created from the provided stringpublic <P extends Page> P getPage(URL url) throws IOException, FailingHttpStatusCodeException
getPage(WebWindow, WebRequest)
.
P
- the page typeurl
- the URL of the new content
FailingHttpStatusCodeException
- if the server returns a failing status code AND the property
setThrowExceptionOnFailingStatusCode(boolean)
is set to true.
IOException
- if an IO problem occurspublic <P extends Page> P getPage(WebRequest request) throws IOException, FailingHttpStatusCodeException
P
- the page typerequest
- the request parameters
FailingHttpStatusCodeException
- if the server returns a failing status code AND the property
setThrowExceptionOnFailingStatusCode(boolean)
is set to true.
IOException
- if an IO problem occursgetPage(WebWindow,WebRequest)
public Page loadWebResponseInto(WebResponse webResponse, WebWindow webWindow) throws IOException, FailingHttpStatusCodeException
Creates a page based on the specified response and inserts it into the specified window. All page initialization and event notification is handled here.
Note that if the page created is an attachment page, and an AttachmentHandler
has been
registered with this client, the page is not loaded into the specified window; in this case,
the page is loaded into a new window, and attachment handling is delegated to the registered
AttachmentHandler.
webResponse
- the response that will be used to create the new pagewebWindow
- the window that the new page will be placed within
IOException
- if an IO error occurs
FailingHttpStatusCodeException
- if the server returns a failing status code AND the property
setThrowExceptionOnFailingStatusCode(boolean)
is set to truesetAttachmentHandler(AttachmentHandler)
public void setPrintContentOnFailingStatusCode(boolean enabled)
enabled
- True to enable this featurepublic boolean getPrintContentOnFailingStatusCode()
setPrintContentOnFailingStatusCode(boolean)
public void printContentIfNecessary(WebResponse webResponse)
Logs the response's content if its status code indicates a request failure and
getPrintContentOnFailingStatusCode()
returns true.
webResponse
- the response whose content may be loggedpublic void setThrowExceptionOnFailingStatusCode(boolean enabled)
enabled
- true to enable this featurepublic boolean isThrowExceptionOnFailingStatusCode()
setThrowExceptionOnFailingStatusCode(boolean)
public void throwFailingHttpStatusCodeExceptionIfNecessary(WebResponse webResponse)
Throws a FailingHttpStatusCodeException
if the request's status code indicates a request
failure and isThrowExceptionOnFailingStatusCode()
returns true.
webResponse
- the response which may trigger a FailingHttpStatusCodeException
public void addRequestHeader(String name, String value)
name
- the name of the header to addvalue
- the value of the header to addremoveRequestHeader(String)
public void removeRequestHeader(String name)
name
- the name of the header to removeaddRequestHeader(java.lang.String, java.lang.String)
public void setCredentialsProvider(CredentialsProvider credentialsProvider)
credentialsProvider
- the new credentials provider to use to authenticatepublic CredentialsProvider getCredentialsProvider()
DefaultCredentialsProvider
.
public com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine getJavaScriptEngine()
null
)public void setJavaScriptEngine(com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine engine)
engine
- the new script engine to usepublic void setJavaScriptEnabled(boolean enabled)
enabled
- true to enable JavaScript supportpublic boolean isJavaScriptEnabled()
public void setCssEnabled(boolean enabled)
enabled
- true to enable CSS supportpublic boolean isCssEnabled()
public void setAppletEnabled(boolean enabled)
Note: as of HtmlUnit-2.4, Applet support is experimental and minimal
enabled
- true to enable Applet supportpublic boolean isAppletEnabled()
public void setPopupBlockerEnabled(boolean enabled)
enabled
- true to enable the popup window blockerpublic boolean isPopupBlockerEnabled()
public String getHomePage()
public void setHomePage(String homePage)
homePage
- the new homepage URLpublic ProxyConfig getProxyConfig()
public void setProxyConfig(ProxyConfig proxyConfig)
proxyConfig
- the proxy configuration for this clientpublic CookieManager getCookieManager()
public void setCookieManager(CookieManager cookieManager)
cookieManager
- the cookie manager used by this web clientpublic void setAlertHandler(AlertHandler alertHandler)
alertHandler
- the new alerthandler or null if none is specifiedpublic AlertHandler getAlertHandler()
public void setConfirmHandler(ConfirmHandler handler)
handler
- the new handler or null if no handler is to be usedpublic ConfirmHandler getConfirmHandler()
public void setPromptHandler(PromptHandler handler)
handler
- the new handler or null if no handler is to be usedpublic PromptHandler getPromptHandler()
public void setStatusHandler(StatusHandler statusHandler)
statusHandler
- the new status handler or null if none is specifiedpublic StatusHandler getStatusHandler()
public BrowserVersion getBrowserVersion()
public WebWindow getCurrentWindow()
public void setCurrentWindow(WebWindow window)
window
- the new "current" window for this clientpublic void addWebWindowListener(WebWindowListener listener)
WebWindowEvent
s. All events from all windows associated with this
client will be sent to the specified listener.
listener
- a listenerpublic void removeWebWindowListener(WebWindowListener listener)
WebWindowEvent
s.
listener
- a listenerpublic WebWindow openWindow(URL url, String windowName)
url
- the URL to load content from or null if no content is to be loadedwindowName
- the name of the new window
public WebWindow openWindow(URL url, String windowName, WebWindow opener)
url
- the URL to load content from or null if no content is to be loadedwindowName
- the name of the new windowopener
- the web window that is calling openWindow
public DialogWindow openDialogWindow(URL url, WebWindow opener, Object dialogArguments) throws IOException
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Opens a new dialog window.
url
- the URL of the document to load and displayopener
- the web window that is opening the dialogdialogArguments
- the object to make available inside the dialog via window.dialogArguments
IOException
- if there is an IO errorpublic void setRedirectEnabled(boolean enabled)
enabled
- true to enable automatic redirectionpublic boolean isRedirectEnabled()
public void setUseInsecureSSL(boolean useInsecureSSL) throws GeneralSecurityException
useInsecureSSL
- whether or not to use insecure SSL
GeneralSecurityException
- if a security error occurspublic void setPageCreator(PageCreator pageCreator)
pageCreator
- the new page creatorpublic PageCreator getPageCreator()
public WebWindow getWebWindowByName(String name) throws WebWindowNotFoundException
WebWindow
that matches the specified name.
name
- the name to search for
WebWindow
with the specified name
WebWindowNotFoundException
- if the WebWindow
can't be foundgetWebWindows()
,
getTopLevelWindows()
public void initialize(WebWindow webWindow)
webWindow
- the new WebWindowpublic void initialize(Page newPage)
newPage
- the new pagepublic void initializeEmptyWindow(WebWindow webWindow)
webWindow
- the new WebWindowpublic void registerWebWindow(WebWindow webWindow)
webWindow
- the new WebWindowpublic void deregisterWebWindow(WebWindow webWindow)
webWindow
- the window to removepublic static URL expandUrl(URL baseUrl, String relativeUrl) throws MalformedURLException
new URL(baseUrl, relativeUrl)
but
there are some cases that URL doesn't handle correctly. See
RFC1808
regarding Relative Uniform Resource Locators for more information.
baseUrl
- the base URLrelativeUrl
- the relative URL
MalformedURLException
- if an error occurred when creating a URL objectpublic String guessContentType(File file)
file
- the file
public WebResponse loadWebResponse(WebRequest webRequest) throws IOException
WebResponse
from the server.
webRequest
- the request
IOException
- if an IO problem occurspublic List<WebWindow> getWebWindows()
getWebWindowByName(String)
,
getTopLevelWindows()
public List<TopLevelWindow> getTopLevelWindows()
getWebWindowByName(String)
,
getWebWindows()
public void setRefreshHandler(RefreshHandler handler)
RefreshHandler
for more details.
handler
- the new handlerpublic RefreshHandler getRefreshHandler()
public void setScriptPreProcessor(ScriptPreProcessor scriptPreProcessor)
scriptPreProcessor
- the new preprocessor or null if none is specifiedpublic ScriptPreProcessor getScriptPreProcessor()
public void setActiveXObjectMap(Map<String,String> activeXObjectMap)
Map
is used to map the
string passed into the ActiveXObject
constructor to a java class name. Therefore
you can emulate ActiveXObject
s in a web page's JavaScript by mapping the object
name to a java class to emulate the active X object.
activeXObjectMap
- the new preprocessor or null if none is specifiedpublic Map<String,String> getActiveXObjectMap()
public void setActiveXNative(boolean allow)
allow
- whether to allow or nopublic boolean isActiveXNative()
public void setHTMLParserListener(HTMLParserListener listener)
listener
- the new listener, null
if messages should be totally ignoredpublic HTMLParserListener getHTMLParserListener()
null
if no listener is defined (default value)public org.w3c.css.sac.ErrorHandler getCssErrorHandler()
DefaultCssErrorHandler
,
SilentCssErrorHandler
public void setCssErrorHandler(org.w3c.css.sac.ErrorHandler cssErrorHandler)
cssErrorHandler
- the CSS error handler used by this web client when CSS problems are encounteredDefaultCssErrorHandler
,
SilentCssErrorHandler
public void setJavaScriptTimeout(long timeout)
timeout
- the timeout value, in millisecondspublic long getJavaScriptTimeout()
public int getTimeout()
WebConnection
.
setTimeout(int)
public void setTimeout(int timeout)
Sets the timeout of the WebConnection
. Set to zero (the default) for an infinite wait.
Note: The timeout is used twice. The first is for making the socket connection, the second is for data retrieval. If the time is critical you must allow for twice the time specified here.
timeout
- the value of the timeout in millisecondspublic boolean isThrowExceptionOnScriptError()
true
if an exception is thrown on script error (the default)public void setThrowExceptionOnScriptError(boolean newValue)
newValue
- indicates if exception should be thrown or notpublic IncorrectnessListener getIncorrectnessListener()
IncorrectnessListenerImpl
.
null
)public void setIncorrectnessListener(IncorrectnessListener listener)
listener
- the new value (not null
)public AjaxController getAjaxController()
public void setAjaxController(AjaxController newValue)
newValue
- the controllerpublic void setAttachmentHandler(AttachmentHandler handler)
handler
- the new attachment handlerpublic AttachmentHandler getAttachmentHandler()
public void setOnbeforeunloadHandler(OnbeforeunloadHandler onbeforeunloadHandler)
onbeforeunloadHandler
- the new onbeforeunloadHandler or null if none is specifiedpublic OnbeforeunloadHandler getOnbeforeunloadHandler()
public Cache getCache()
public void setCache(Cache cache)
cache
- the new cache (must not be null
)public void closeAllWindows()
public int waitForBackgroundJavaScript(long timeoutMillis)
Experimental API: May be changed in next release and may not yet work perfectly!
This method blocks until all background JavaScript tasks have finished executing. Background JavaScript tasks are JavaScript tasks scheduled for execution via window.setTimeout, window.setInterval or asynchronous XMLHttpRequest.
If a job is scheduled to begin executing after (now + timeoutMillis), this method will wait for timeoutMillis milliseconds and then return a value greater than 0. This method will never block longer than timeoutMillis milliseconds.
Use this method instead of waitForBackgroundJavaScriptStartingBefore(long)
if you
don't know when your background JavaScript is supposed to start executing, but you're fairly sure
that you know how long it should take to finish executing.
timeoutMillis
- the maximum amount of time to wait (in milliseconds)
public int waitForBackgroundJavaScriptStartingBefore(long delayMillis)
Experimental API: May be changed in next release and may not yet work perfectly!
This method blocks until all background JavaScript tasks scheduled to start executing before (now + delayMillis) have finished executing. Background JavaScript tasks are JavaScript tasks scheduled for execution via window.setTimeout, window.setInterval or asynchronous XMLHttpRequest.
If there is no background JavaScript task currently executing, and there is no background JavaScript task scheduled to start executing within the specified time, this method returns immediately -- even if there are tasks scheduled to be executed after (now + delayMillis).
Note that the total time spent executing a background JavaScript task is never known ahead of time, so this method makes no guarantees as to how long it will block.
Use this method instead of waitForBackgroundJavaScript(long)
if you know roughly when
your background JavaScript is supposed to start executing, but you're not necessarily sure how long
it will take to execute.
delayMillis
- the delay which determines the background tasks to wait for (in milliseconds)
public void download(WebWindow requestingWindow, String target, WebRequest request, String description)
requestingWindow
- the window from which the request comestarget
- the name of the target windowrequest
- the request to performdescription
- information about the origin of the request. Useful for debugging.public void loadDownloadedResponses() throws FailingHttpStatusCodeException, IOException
IOException
- in case of exception
FailingHttpStatusCodeException
- in case of exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |