Java Doc for WebClient.java in  » Testing » htmlunit » com » gargoylesoftware » htmlunit » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » htmlunit » com.gargoylesoftware.htmlunit 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.gargoylesoftware.htmlunit.WebClient

WebClient
public class WebClient implements Serializable(Code)
An object that represents a web browser.
version:
   $Revision: 2161 $
author:
   Mike Bowler
author:
   Mike J. Bresnahan
author:
   Dominique Broeglin
author:
   Noboru Sinohara
author:
   Chen Jun
author:
   David K. Taylor
author:
   Christian Sell
author:
   Ben Curren
author:
   Marc Guillemot
author:
   Chris Erskine
author:
   Daniel Gredler
author:
   Sergey Gorelkin
author:
   Hans Donner
author:
   Paul King
author:
   Ahmed Ashour


Field Summary
final public static  StringHTMLUNIT_COOKIE_POLICY
     HtmlUnit's cookie policy is to be browser-compatible.
final public static  URLURL_ABOUT_BLANK
    

Constructor Summary
public  WebClient()
     Creates a web client instance using the browser version returned by BrowserVersion.getDefault .
public  WebClient(BrowserVersion browserVersion)
     Creates a web client instance using the specified BrowserVersion .
public  WebClient(BrowserVersion browserVersion, String proxyHost, int proxyPort)
    

Method Summary
public  voidaddHostsToProxyBypass(String pattern)
     Any hosts matched by the specified regular expression pattern will bypass the configured proxy.
public  voidaddRequestHeader(String name, String value)
     Set a header which will be sent up on EVERY request from this client.
public  voidaddWebWindowListener(WebWindowListener listener)
     Add a listener for WebWindowEvent's.
public  voidassertionFailed(String message)
     Throw an exception with the specified message.
public  voidderegisterWebWindow(WebWindow webWindow)
     INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Remove a web window from the list of available windows.
protected  URLencodeUrl(URL url)
     Encodes illegal parameter in path or query string (if any) as done by browsers.
public static  URLexpandUrl(URL baseUrl, String relativeUrl)
     Expands a relative url relative to the specified base.
public  MapgetActiveXObjectMap()
     Return the active X object map for this webclient.
public  AjaxControllergetAjaxController()
    
public  AlertHandlergetAlertHandler()
     Return the alert handler for this webclient.
public  BrowserVersiongetBrowserVersion()
    
public  CachegetCache()
    
public  ConfirmHandlergetConfirmHandler()
     Return the confirm handler.
public  CredentialsProvidergetCredentialsProvider()
     Returns the credentials provider for this client instance.
public  WebWindowgetCurrentWindow()
     Return the "current" window for this client.
public  HTMLParserListenergetHTMLParserListener()
     Gets the configured listener for messages generated by the html parser.
public  StringgetHomePage()
     Returns the client's current homepage.
public static  booleangetIgnoreOutsideContent()
    
public  IncorrectnessListenergetIncorrectnessListener()
     Gets the current listener for encountered incorrectness (except HTML parsing messages that are handled by the HTML parser listener).
public  JavaScriptEnginegetJavaScriptEngine()
     This method is intended for testing only - use at your own risk.
final protected  LoggetLog()
    
public  OnbeforeunloadHandlergetOnbeforeunloadHandler()
     Return the onbeforeunload handler for this webclient.
public  PagegetPage(WebWindow webWindow, WebRequestSettings parameters)
     Send a request to a server and return a Page that represents the response from the server.
public  PagegetPage(WebWindow opener, String target, WebRequestSettings params)
     INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.

Open a new web window and populate it with a page loaded by WebClient.getPage(WebWindow,WebRequestSettings)


Parameters:
  opener - The web window that initiated the request.
Parameters:
  target - The name of the window to be opened.
public  PagegetPage(String url)
     Convenient method to build an URL and load it into the current WebWindow
Parameters:
  url - The url of the new content.
public  PagegetPage(URL url)
     Convenient method to load a URL into the current WebWindow
Parameters:
  url - The url of the new content.
public  PagegetPage(WebRequestSettings request)
    
public  PageCreatorgetPageCreator()
     Return the current page creator.
public  booleangetPrintContentOnFailingStatusCode()
     Return true if the content of the resulting document will be printed to the console in the event of a failing response code.
public  PromptHandlergetPromptHandler()
     Return the prompt handler.
public  RefreshHandlergetRefreshHandler()
     Return the current refresh handler or null if one has not been set.
public  ScriptPreProcessorgetScriptPreProcessor()
     Return the script pre processor for this webclient.
public  StatusHandlergetStatusHandler()
     Return the status handler for this webclient.
public  intgetTimeout()
    
public synchronized  WebConnectiongetWebConnection()
    
public  WebWindowgetWebWindowByName(String name)
     Return the first WebWindow that matches the specified name.
Parameters:
  name - The name to search for.
public  ListgetWebWindows()
     Return an immutable list of open web windows (top windows or not).
public  StringguessContentType(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".
public  voidinitialize(WebWindow webWindow)
     INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Initialize a new web window for JavaScript.
public  voidinitialize(Page newPage)
     INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Initialize a new page for JavaScript.
public  voidinitializeEmptyWindow(WebWindow webWindow)
     INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Initialize a new empty web window for JavaScript.
public  booleanisCookiesEnabled()
     Returns true if cookies are enabled.
public  booleanisJavaScriptEnabled()
     Returns true if JavaScript is enabled and the script engine was loaded successfully.
public  booleanisPopupBlockerEnabled()
     Returns true if the popup window blocker is enabled.
public  booleanisRedirectEnabled()
     Return whether or not redirections will be followed automatically on receipt of a redirect status code from the server.
public  booleanisThrowExceptionOnFailingStatusCode()
     Return true if an exception will be thrown in the event of a failing response code.
public  booleanisThrowExceptionOnScriptError()
     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.
public  WebResponseloadWebResponse(WebRequestSettings webRequestSettings)
    
public  PageloadWebResponseInto(WebResponse webResponse, WebWindow webWindow)
     Use the specified WebResponse to create a Page object which will then get inserted into the WebWindow.
public  WebWindowopenWindow(URL url, String windowName)
     Open a new window with the specified name.
public  WebWindowopenWindow(URL url, String windowName, WebWindow opener)
     Open a new window with the specified name.
public  WebWindowpopFirstWindow()
     Return the "first" window for this client.
public  voidprintContentIfNecessary(WebResponse webResponse)
     INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.

Logs the response's content if its status code indicates a request failure and WebClient.getPrintContentOnFailingStatusCode() returns true.

public  voidpushClearFirstWindow()
     Clear the first window for this client.
public  voidregisterWebWindow(WebWindow webWindow)
     INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Add a new web window to the list of available windows.
public  voidremoveHostsFromProxyBypass(String pattern)
     Any hosts matched by the specified regular expression pattern will no longer bypass the configured proxy.
public  voidremoveRequestHeader(String name)
    
public  voidremoveWebWindowListener(WebWindowListener listener)
     Remove a listener for WebWindowEvent's.
public  voidsetActiveXObjectMap(Map activeXObjectMap)
     Set the active X object map for this webclient.
public  voidsetAjaxController(AjaxController newValue)
    
public  voidsetAlertHandler(AlertHandler alertHandler)
     Set the alert handler for this webclient.
public  voidsetCache(Cache cache)
    
public  voidsetConfirmHandler(ConfirmHandler handler)
     Set the handler that will be executed when the javascript method Window.confirm() is called.
public  voidsetCookiesEnabled(boolean enabled)
     Enable/disable cookie support.
public  voidsetCredentialsProvider(CredentialsProvider credentialsProvider)
     Sets the credentials provider that will provide authentication information when trying to access protected information on a web server.
public  voidsetCurrentWindow(WebWindow window)
     Set the current window for this client.
public  voidsetHTMLParserListener(HTMLParserListener listener)
     Defines a listener for messages generated by the html parser.
Note: If WebClient.getIgnoreOutsideContent() returns false, the parser will ignore closing <body> and <html> tags to be able to handle html content incorrectly located after the end of the html file.
public  voidsetHomePage(String homePage)
     Sets the client's homepage.
public static  voidsetIgnoreOutsideContent(boolean ignoreOutsideContent)
     Set the flag on the HtmlParse to ignore the content that is outside of the BODY and HTML tags.
public  voidsetIncorrectnessListener(IncorrectnessListener listener)
     Returns the current HTML incorrectness listener.
public  voidsetJavaScriptEnabled(boolean enabled)
     Enable/disable JavaScript support.
public  voidsetJavaScriptEngine(JavaScriptEngine engine)
     This method is intended for testing only - use at your own risk.
public  voidsetOnbeforeunloadHandler(OnbeforeunloadHandler onbeforeunloadHandler)
     Set the onbeforeunload handler for this webclient.
public  voidsetPageCreator(PageCreator pageCreator)
     Set the object that will be used to create pages.
public  voidsetPopupBlockerEnabled(boolean enabled)
     Enable/disable the popup window blocker.
public  voidsetPrintContentOnFailingStatusCode(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. Successful response codes are in the range 200-299.
public  voidsetPromptHandler(PromptHandler handler)
     Set the handler that will be executed when the javascript method Window.prompt() is called.
public  voidsetRedirectEnabled(boolean enabled)
     Set whether or not redirections will be followed automatically on receipt of a redirect status code from the server.
public  voidsetRefreshHandler(RefreshHandler handler)
     Set the handler to be used whenever a refresh is triggered.
public  voidsetScriptPreProcessor(ScriptPreProcessor scriptPreProcessor)
     Set the script pre processor for this webclient.
public  voidsetStatusHandler(StatusHandler statusHandler)
     Set the status handler for this webclient.
public  voidsetThrowExceptionOnFailingStatusCode(boolean enabled)
     Specify whether or not an exception will be thrown in the event of a failing status code.
public  voidsetThrowExceptionOnScriptError(boolean newValue)
     Changes the behavior of this webclient when a script error occurs.
public  voidsetTimeout(int timeout)
     Sets the timeout of the WebConnection.
public  voidsetUseInsecureSSL(boolean useInsecureSSL)
     If set to true, the client will accept connections to any host, regardless of whether they have valid certificates or not.
public  voidsetWebConnection(WebConnection webConnection)
     Set the object that will resolve all url requests

This method is intended for unit testing HtmlUnit itself.

public  voidthrowFailingHttpStatusCodeExceptionIfNecessary(WebResponse webResponse)
     INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.

Throws a FailingHttpStatusCodeException if the request's status code indicates a request failure and WebClient.isThrowExceptionOnFailingStatusCode() returns true.


Field Detail
HTMLUNIT_COOKIE_POLICY
final public static String HTMLUNIT_COOKIE_POLICY(Code)
HtmlUnit's cookie policy is to be browser-compatible. Code which requires access to HtmlUnit's cookie policy should use this constant, rather than making assumptions and using one of the HttpClient CookiePolicy constants directly.



URL_ABOUT_BLANK
final public static URL URL_ABOUT_BLANK(Code)
URL for "about:blank"




Constructor Detail
WebClient
public WebClient()(Code)
Creates a web client instance using the browser version returned by BrowserVersion.getDefault .



WebClient
public WebClient(BrowserVersion browserVersion)(Code)
Creates a web client instance using the specified BrowserVersion .
Parameters:
  browserVersion - The browser version to simulate.



WebClient
public WebClient(BrowserVersion browserVersion, String proxyHost, int proxyPort)(Code)
Create an instance that will use the specified BrowserVersion and proxy server
Parameters:
  browserVersion - The browser version to simulate
Parameters:
  proxyHost - The server that will act as proxy
Parameters:
  proxyPort - The port to use on the proxy server




Method Detail
addHostsToProxyBypass
public void addHostsToProxyBypass(String pattern)(Code)
Any hosts matched by the specified regular expression pattern will bypass the configured proxy.
Parameters:
  pattern - A regular expression pattern that matches the hostnames of the hosts which shouldbypass the configured proxy.
See Also:   Pattern



addRequestHeader
public void addRequestHeader(String name, String value)(Code)
Set a header which will be sent up on EVERY request from this client.
Parameters:
  name - The name of the header
Parameters:
  value - The value of the header



addWebWindowListener
public void addWebWindowListener(WebWindowListener listener)(Code)
Add a listener for WebWindowEvent's. All events from all windows associated with this client will be sent to the specified listener.
Parameters:
  listener - A listener.



assertionFailed
public void assertionFailed(String message)(Code)
Throw an exception with the specified message. If junit is found in the classpath then a junit.framework.AssertionFailedError will be thrown (the same behavior as calling fail() in junit). If junit is not found then an IllegalStateException will be thrown instead of the AssertionFailedError.

Override this to provide custom behavior.
Parameters:
  message - The failure message
See Also:   WebAssert




deregisterWebWindow
public void deregisterWebWindow(WebWindow webWindow)(Code)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Remove a web window from the list of available windows.
Parameters:
  webWindow - The WebWindow to remove



encodeUrl
protected URL encodeUrl(URL url) throws MalformedURLException, URIException(Code)
Encodes illegal parameter in path or query string (if any) as done by browsers. Example: changes "http://first?a=b c" to "http://first?a=b%20c"
Parameters:
  url - the url to encode the provided url if no change needed, the fixed url else
throws:
  MalformedURLException - if the new URL could note be instantiated
throws:
  URIException - if the default protocol charset is not supported



expandUrl
public static URL expandUrl(URL baseUrl, String relativeUrl) throws MalformedURLException(Code)
Expands a relative url relative to the specified base. In most situations this is the same as 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.
Parameters:
  baseUrl - The base url
Parameters:
  relativeUrl - The relative url See above
throws:
  MalformedURLException - If an error occurred when creating a URL object



getActiveXObjectMap
public Map getActiveXObjectMap()(Code)
Return the active X object map for this webclient. the active X object map.



getAjaxController
public AjaxController getAjaxController()(Code)
Gets the current Ajax controller the controller



getAlertHandler
public AlertHandler getAlertHandler()(Code)
Return the alert handler for this webclient. the alert handler or null if one hasn't been set.



getBrowserVersion
public BrowserVersion getBrowserVersion()(Code)
Return the current browser version the current browser version.



getCache
public Cache getCache()(Code)
Gets the cache currently used the cache (may not be null)



getConfirmHandler
public ConfirmHandler getConfirmHandler()(Code)
Return the confirm handler. the confirm handler or null if one hasn't been set.



getCredentialsProvider
public CredentialsProvider getCredentialsProvider()(Code)
Returns the credentials provider for this client instance. By default, this method returns an instance of DefaultCredentialsProvider . The credentials provider for this client instance.



getCurrentWindow
public WebWindow getCurrentWindow()(Code)
Return the "current" window for this client. This is the window that will be used when getPage() is called without specifying a window. The current window.



getHTMLParserListener
public HTMLParserListener getHTMLParserListener()(Code)
Gets the configured listener for messages generated by the html parser. null if no listener is defined (default value).



getHomePage
public String getHomePage()(Code)
Returns the client's current homepage. the client's current homepage.



getIgnoreOutsideContent
public static boolean getIgnoreOutsideContent()(Code)
Get the state of the flag to ignore content outside the BODY and HTML tags - The current state



getIncorrectnessListener
public IncorrectnessListener getIncorrectnessListener()(Code)
Gets the current listener for encountered incorrectness (except HTML parsing messages that are handled by the HTML parser listener). Default value is an instance of IncorrectnessListenerImpl . the current listener (not null).



getJavaScriptEngine
public JavaScriptEngine getJavaScriptEngine()(Code)
This method is intended for testing only - use at your own risk. the current JavaScript engine (never null).



getLog
final protected Log getLog()(Code)
Return the log object for this web client The log object



getOnbeforeunloadHandler
public OnbeforeunloadHandler getOnbeforeunloadHandler()(Code)
Return the onbeforeunload handler for this webclient. the onbeforeunload handler or null if one hasn't been set.



getPage
public Page getPage(WebWindow webWindow, WebRequestSettings parameters) throws IOException, FailingHttpStatusCodeException(Code)
Send a request to a server and return a Page that represents the response from the server. This page will be used to populate this frame.

The type of Page will depend on the content type of the http response.

Content type Type of page
"text/html" com.gargoylesoftware.htmlunit.html.HtmlPage
"text/xhtml" com.gargoylesoftware.htmlunit.html.HtmlPage
"application/xhtml+xml" com.gargoylesoftware.htmlunit.html.HtmlPage for now, in the future it will be XML validated as well
"text/*" com.gargoylesoftware.htmlunit.TextPage
Anything else com.gargoylesoftware.htmlunit.UnexpectedPage

Parameters:
  webWindow - The WebWindow to load this request into
Parameters:
  parameters - Parameter object for the web request See above
throws:
  IOException - If an IO error occurs
throws:
  FailingHttpStatusCodeException - If the server returns a failing status code AND the propertyWebClient.setThrowExceptionOnFailingStatusCode(boolean) is set to true
See Also:   WebRequestSettings




getPage
public Page getPage(WebWindow opener, String target, WebRequestSettings params) throws FailingHttpStatusCodeException, IOException(Code)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.

Open a new web window and populate it with a page loaded by WebClient.getPage(WebWindow,WebRequestSettings)


Parameters:
  opener - The web window that initiated the request.
Parameters:
  target - The name of the window to be opened. This is the name that wouldbe passed into the javascript open() method.
Parameters:
  params - Any parameters The new page.
throws:
  FailingHttpStatusCodeException - If the server returns a failing status code AND the propertyWebClient.setThrowExceptionOnFailingStatusCode(boolean) is set to true.
throws:
  IOException - If an IO problem occurs.



getPage
public Page getPage(String url) throws IOException, FailingHttpStatusCodeException, MalformedURLException(Code)
Convenient method to build an URL and load it into the current WebWindow
Parameters:
  url - The url of the new content. The new page.
throws:
  FailingHttpStatusCodeException - If the server returns a failing status code AND the propertyWebClient.setThrowExceptionOnFailingStatusCode(boolean) is set to true.
throws:
  IOException - If an IO problem occurs.
throws:
  MalformedURLException - if no url can be created from the provided string



getPage
public Page getPage(URL url) throws IOException, FailingHttpStatusCodeException(Code)
Convenient method to load a URL into the current WebWindow
Parameters:
  url - The url of the new content. The new page.
throws:
  FailingHttpStatusCodeException - If the server returns a failing status code AND the propertyWebClient.setThrowExceptionOnFailingStatusCode(boolean) is set to true.
throws:
  IOException - If an IO problem occurs.



getPage
public Page getPage(WebRequestSettings request) throws IOException, FailingHttpStatusCodeException(Code)
Convenient method to load a web request into the current WebWindow
Parameters:
  request - The request parameters The new page.
throws:
  FailingHttpStatusCodeException - If the server returns a failing status code AND the propertyWebClient.setThrowExceptionOnFailingStatusCode(boolean) is set to true.
throws:
  IOException - If an IO problem occurs.
See Also:   WebClient.getPage(WebWindow,WebRequestSettings)



getPageCreator
public PageCreator getPageCreator()(Code)
Return the current page creator. the page creator



getPrintContentOnFailingStatusCode
public boolean getPrintContentOnFailingStatusCode()(Code)
Return true if the content of the resulting document will be printed to the console in the event of a failing response code. See above
See Also:   WebClient.setPrintContentOnFailingStatusCode



getPromptHandler
public PromptHandler getPromptHandler()(Code)
Return the prompt handler. the prompt handler or null if one hasn't been set.



getRefreshHandler
public RefreshHandler getRefreshHandler()(Code)
Return the current refresh handler or null if one has not been set. The current RefreshHandler or null



getScriptPreProcessor
public ScriptPreProcessor getScriptPreProcessor()(Code)
Return the script pre processor for this webclient. the pre processor or null of one hasn't been set.



getStatusHandler
public StatusHandler getStatusHandler()(Code)
Return the status handler for this webclient. the status handler or null if one hasn't been set.



getTimeout
public int getTimeout()(Code)
Gets the timeout value for the WebConnection The timeout value in milliseconds
See Also:   WebClient.setTimeout(int)



getWebConnection
public synchronized WebConnection getWebConnection()(Code)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.

Return the object that will resolve all url requests

The connection that will be used.




getWebWindowByName
public WebWindow getWebWindowByName(String name) throws WebWindowNotFoundException(Code)
Return the first WebWindow that matches the specified name.
Parameters:
  name - The name to search for. The WebWindow with the specified name
throws:
  WebWindowNotFoundException - If the WebWindow can't be found.



getWebWindows
public List getWebWindows()(Code)
Return an immutable list of open web windows (top windows or not). The web windows



guessContentType
public String guessContentType(File file)(Code)
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".
Parameters:
  file - the file "application/octet-stream" if nothing could be guessed.



initialize
public void initialize(WebWindow webWindow)(Code)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Initialize a new web window for JavaScript.
Parameters:
  webWindow - The new WebWindow



initialize
public void initialize(Page newPage)(Code)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Initialize a new page for JavaScript.
Parameters:
  newPage - The new page.



initializeEmptyWindow
public void initializeEmptyWindow(WebWindow webWindow)(Code)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Initialize a new empty web window for JavaScript.
Parameters:
  webWindow - The new WebWindow



isCookiesEnabled
public boolean isCookiesEnabled()(Code)
Returns true if cookies are enabled. true if cookies are enabled



isJavaScriptEnabled
public boolean isJavaScriptEnabled()(Code)
Returns true if JavaScript is enabled and the script engine was loaded successfully. true if JavaScript is enabled



isPopupBlockerEnabled
public boolean isPopupBlockerEnabled()(Code)
Returns true if the popup window blocker is enabled. true if the popup window blocker is enabled



isRedirectEnabled
public boolean isRedirectEnabled()(Code)
Return whether or not redirections will be followed automatically on receipt of a redirect status code from the server. true if automatic redirection is enabled.



isThrowExceptionOnFailingStatusCode
public boolean isThrowExceptionOnFailingStatusCode()(Code)
Return true if an exception will be thrown in the event of a failing response code. See above
See Also:   WebClient.setThrowExceptionOnFailingStatusCode



isThrowExceptionOnScriptError
public boolean isThrowExceptionOnScriptError()(Code)
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. true if an exception is thrown on script error (the default)



loadWebResponse
public WebResponse loadWebResponse(WebRequestSettings webRequestSettings) throws IOException(Code)
Loads a WebResponse from the server
Parameters:
  webRequestSettings - settings to use when making the request
throws:
  IOException - if an IO problem occurs The WebResponse



loadWebResponseInto
public Page loadWebResponseInto(WebResponse webResponse, WebWindow webWindow) throws IOException, FailingHttpStatusCodeException(Code)
Use the specified WebResponse to create a Page object which will then get inserted into the WebWindow. All initialization and event notification will be handled here.
Parameters:
  webResponse - The response that will be used to create the new page.
Parameters:
  webWindow - The window that the new page will be placed within.
throws:
  IOException - If an IO error occurs.
throws:
  FailingHttpStatusCodeException - If the server returns a failing status code AND the propertyWebClient.setThrowExceptionOnFailingStatusCode(boolean) is set to true The newly created page.



openWindow
public WebWindow openWindow(URL url, String windowName)(Code)
Open a new window with the specified name. If the url is non-null then attempt to load a page from that location and put it in the new window.
Parameters:
  url - The url to load content from or null if no content is to be loaded.
Parameters:
  windowName - The name of the new window The new window.



openWindow
public WebWindow openWindow(URL url, String windowName, WebWindow opener)(Code)
Open a new window with the specified name. If the url is non-null then attempt to load a page from that location and put it in the new window.
Parameters:
  url - The url to load content from or null if no content is to be loaded.
Parameters:
  windowName - The name of the new window
Parameters:
  opener - The web window that is calling openWindow The new window.



popFirstWindow
public WebWindow popFirstWindow()(Code)
Return the "first" window for this client. This is the first window opened since pushClearFirstWindow() was last called. The first window.



printContentIfNecessary
public void printContentIfNecessary(WebResponse webResponse)(Code)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.

Logs the response's content if its status code indicates a request failure and WebClient.getPrintContentOnFailingStatusCode() returns true.
Parameters:
  webResponse - the response whose content may be logged




pushClearFirstWindow
public void pushClearFirstWindow()(Code)
Clear the first window for this client.



registerWebWindow
public void registerWebWindow(WebWindow webWindow)(Code)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Add a new web window to the list of available windows.
Parameters:
  webWindow - The new WebWindow



removeHostsFromProxyBypass
public void removeHostsFromProxyBypass(String pattern)(Code)
Any hosts matched by the specified regular expression pattern will no longer bypass the configured proxy.
Parameters:
  pattern - The previously added regular expression pattern.
See Also:   Pattern



removeRequestHeader
public void removeRequestHeader(String name)(Code)
Remove a header
Parameters:
  name - Name of the header
See Also:   WebClient.addRequestHeader



removeWebWindowListener
public void removeWebWindowListener(WebWindowListener listener)(Code)
Remove a listener for WebWindowEvent's.
Parameters:
  listener - A listener.



setActiveXObjectMap
public void setActiveXObjectMap(Map activeXObjectMap)(Code)
Set the active X object map for this webclient. The Map is used to map the string passed into the ActiveXObject constructor to a java class name. Therefore you can emulate ActiveXObjects in a web page's javascript by mapping the object name to a java class to emulate the active X object.
Parameters:
  activeXObjectMap - The new preprocessor or null if none is specified



setAjaxController
public void setAjaxController(AjaxController newValue)(Code)
Sets the current Ajax controller EXPERIMENTAL - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.

Parameters:
  newValue - the controller



setAlertHandler
public void setAlertHandler(AlertHandler alertHandler)(Code)
Set the alert handler for this webclient.
Parameters:
  alertHandler - The new alerthandler or null if none is specified.



setCache
public void setCache(Cache cache)(Code)
Sets the cache to use
Parameters:
  cache - the new cache (must not be null)



setConfirmHandler
public void setConfirmHandler(ConfirmHandler handler)(Code)
Set the handler that will be executed when the javascript method Window.confirm() is called.
Parameters:
  handler - The new handler or null if no handler is to be used.



setCookiesEnabled
public void setCookiesEnabled(boolean enabled)(Code)
Enable/disable cookie support. By default, this property is enabled.
Parameters:
  enabled - true to enable cookie support



setCredentialsProvider
public void setCredentialsProvider(CredentialsProvider credentialsProvider)(Code)
Sets the credentials provider that will provide authentication information when trying to access protected information on a web server. This information is required when the server is using Basic HTTP authentication, NTLM authentication, or Digest authentication.
Parameters:
  credentialsProvider - The new credentials provider to use to authenticate.



setCurrentWindow
public void setCurrentWindow(WebWindow window)(Code)
Set the current window for this client. This is the window that will be used when getPage() is called without specifying a window.
Parameters:
  window - The new window.



setHTMLParserListener
public void setHTMLParserListener(HTMLParserListener listener)(Code)
Defines a listener for messages generated by the html parser.
Note: If WebClient.getIgnoreOutsideContent() returns false, the parser will ignore closing <body> and <html> tags to be able to handle html content incorrectly located after the end of the html file. As a consequence it will finally notify as errors that <body> and <html> are not closed properly even if they were correctly present.
Parameters:
  listener - the new listener, null if messages should be totally ignored.



setHomePage
public void setHomePage(String homePage)(Code)
Sets the client's homepage.
Parameters:
  homePage - the new homepage URL



setIgnoreOutsideContent
public static void setIgnoreOutsideContent(boolean ignoreOutsideContent)(Code)
Set the flag on the HtmlParse to ignore the content that is outside of the BODY and HTML tags.
Parameters:
  ignoreOutsideContent - The boolean flag to enable or disable the support ofcontent outside of the HTML and BODY tags



setIncorrectnessListener
public void setIncorrectnessListener(IncorrectnessListener listener)(Code)
Returns the current HTML incorrectness listener.
Parameters:
  listener - the new value (not null)



setJavaScriptEnabled
public void setJavaScriptEnabled(boolean enabled)(Code)
Enable/disable JavaScript support. By default, this property is enabled.
Parameters:
  enabled - true to enable JavaScript support



setJavaScriptEngine
public void setJavaScriptEngine(JavaScriptEngine engine)(Code)
This method is intended for testing only - use at your own risk.
Parameters:
  engine - The new script engine to use.



setOnbeforeunloadHandler
public void setOnbeforeunloadHandler(OnbeforeunloadHandler onbeforeunloadHandler)(Code)
Set the onbeforeunload handler for this webclient.
Parameters:
  onbeforeunloadHandler - The new onbeforeunloadHandler or null if none is specified.



setPageCreator
public void setPageCreator(PageCreator pageCreator)(Code)
Set the object that will be used to create pages. Set this if you want to customize the type of page that is returned for a given content type.
Parameters:
  pageCreator - The new page creator



setPopupBlockerEnabled
public void setPopupBlockerEnabled(boolean enabled)(Code)
Enable/disable the popup window blocker. By default, the popup blocker is disabled, and popup windows are allowed. When set to true, window.open() has no effect and returns null.
Parameters:
  enabled - true to enable the popup window blocker



setPrintContentOnFailingStatusCode
public void setPrintContentOnFailingStatusCode(boolean enabled)(Code)
Specify whether or not the content of the resulting document will be printed to the console in the event of a failing response code. Successful response codes are in the range 200-299. The default is true.
Parameters:
  enabled - True to enable this feature



setPromptHandler
public void setPromptHandler(PromptHandler handler)(Code)
Set the handler that will be executed when the javascript method Window.prompt() is called.
Parameters:
  handler - The new handler or null if no handler is to be used.



setRedirectEnabled
public void setRedirectEnabled(boolean enabled)(Code)
Set whether or not redirections will be followed automatically on receipt of a redirect status code from the server.
Parameters:
  enabled - true to enable automatic redirection.



setRefreshHandler
public void setRefreshHandler(RefreshHandler handler)(Code)
Set the handler to be used whenever a refresh is triggered. Refer to the documentation for RefreshHandler for more details.
Parameters:
  handler - The new handler



setScriptPreProcessor
public void setScriptPreProcessor(ScriptPreProcessor scriptPreProcessor)(Code)
Set the script pre processor for this webclient.
Parameters:
  scriptPreProcessor - The new preprocessor or null if none is specified



setStatusHandler
public void setStatusHandler(StatusHandler statusHandler)(Code)
Set the status handler for this webclient.
Parameters:
  statusHandler - The new alerthandler or null if none is specified.



setThrowExceptionOnFailingStatusCode
public void setThrowExceptionOnFailingStatusCode(boolean enabled)(Code)
Specify whether or not an exception will be thrown in the event of a failing status code. Successful status codes are in the range 200-299. The default is true.
Parameters:
  enabled - True to enable this feature



setThrowExceptionOnScriptError
public void setThrowExceptionOnScriptError(boolean newValue)(Code)
Changes the behavior of this webclient when a script error occurs.
Parameters:
  newValue - indicates if exception should be thrown or not



setTimeout
public void setTimeout(int timeout)(Code)
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.
Parameters:
  timeout - The value of the timeout in milliseconds



setUseInsecureSSL
public void setUseInsecureSSL(boolean useInsecureSSL) throws GeneralSecurityException(Code)
If set to true, the client will accept connections to any host, regardless of whether they have valid certificates or not. This is especially useful when you are trying to connect to a server with expired or corrupt certificates.
Parameters:
  useInsecureSSL - whether or not to use insecure SSL
throws:
  GeneralSecurityException - if a security error occurs



setWebConnection
public void setWebConnection(WebConnection webConnection)(Code)
Set the object that will resolve all url requests

This method is intended for unit testing HtmlUnit itself. It is not expected to change but you shouldn't need to call it during normal use of HtmlUnit.
Parameters:
  webConnection - The new web connection




throwFailingHttpStatusCodeExceptionIfNecessary
public void throwFailingHttpStatusCodeExceptionIfNecessary(WebResponse webResponse)(Code)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.

Throws a FailingHttpStatusCodeException if the request's status code indicates a request failure and WebClient.isThrowExceptionOnFailingStatusCode() returns true.
Parameters:
  webResponse - the response which may trigger a FailingHttpStatusCodeException




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.