com.jniwrapper.win32.ie
Class HeadlessBrowser

java.lang.Object
  extended by com.jniwrapper.win32.ie.HeadlessBrowser
All Implemented Interfaces:
ParentWindow, WebBrowser

public class HeadlessBrowser
extends java.lang.Object
implements WebBrowser

This class is the windowless implementation of WebBrowser iterface, specially designed for such operations that do not require a Java component.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jniwrapper.win32.ie.WebBrowser
WebBrowser.Properties
 
Constructor Summary
HeadlessBrowser()
          Creates Internet Explorer wrapper for automated testing.
HeadlessBrowser(HeadlessBrowser parent)
           
 
Method Summary
 void addBrowserWindowListener(BrowserWindowListener listener)
          Adds window listener.
 void addDisposeListener(DisposeListener listener)
          Registers the listener for the current Browser instance that will receive events when the current Browser instance is disposed.
 void addNavigationListener(NavigationEventListener listener)
          Adds browser navigation event listener.
 void addNewWindowListener(NewWindowEventListener listener)
          Adds new window listener.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Adds a new property change listener.
 void addStatusListener(StatusEventListener listener)
          Adds browser status event listener.
 void close()
          Closes browser instance.
 void execute(BrowserCommand command)
          Executes specified command.
 java.lang.Object executeScript(java.lang.String javaScript)
          Executes specified JavaScript code in a currently opened document.
 AuthenticationHandler getAuthenticationHandler()
          Returns the current browser authentication handler or null if it's was not specified.
 java.lang.Object getBrowserPeer()
          Returns an instance of the native web browser peer.
 java.lang.String getContent()
          Returns the HTML content of a document, opened in a browser.
 java.lang.String getContent(boolean original)
          Returns the string that represents HTML content of a currently loaded document in WebBrowser.
 java.util.Set<Cookie> getCookies(java.lang.String url)
          Deprecated. Use the CookieManager.getCookies(URL url) method instead.
 java.util.Set<Cookie> getCookies(java.net.URL url)
          Returns cookies, that are associated with the specified URL.
 DialogEventHandler getDialogEventHandler()
          Returns the dialog events handler or null if it's was not specified.
 DisposeListener[] getDisposeListeners()
          Returns an array of all registered listeners for the current Browser instance.
 org.w3c.dom.html.HTMLDocument getDocument()
          Returns an instance of HTMLDocument that represents the HTML document currently loaded into the WebBrowser and provides access to the contents of the HTML Document Object Model (DOM).
 WebBrowserEventsHandler getEventHandler()
          Returns browser event handler.
 HtmlDialogListener getHtmlDialogListener()
          Returns the current HTML Dialog listener or null if it's not registered.
 HttpSecurityHandler getHttpSecurityHandler()
          Returns http security handler that allows processing any security problems or null if it's not present.
 KeyFilter getKeyFilter()
          Returns key filter.
 java.lang.String getLocationURL()
          Returns the string that represents a URL of the resource that WebBrowser component is currently displayed.
 java.util.List<NavigationEventListener> getNavigationListeners()
          Returns browser navigation event listeners.
 NewWindowEventHandler getNewWindowHandler()
          Returns new window handler.
 java.util.List<NewWindowEventListener> getNewWindowListeners()
          Returns new window listeners.
 com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
          Return browser OLE message loop.
 BrowserOptions getOptions()
           
 WebBrowser getParentBrowser()
          Returns the parent of the browser.
 WebBrowser.Properties getProperties()
          Returns extended browser properties.
 ProxyConfiguration getProxy()
          Returns the proxy settings for the current WebBrowser control.
 ReadyState getReadyState()
          Returns the current ReadyState of the browser.
 WebBrowser getRecentChild()
          Returns recent created child object since last trackChildren() method call.
 ScriptErrorListener getScriptErrorListener()
          Returns script error listener for current page.
 java.util.List<StatusEventListener> getStatusListeners()
          Returns browser status event listeners.
 int getZoomValue()
           
 void goBack()
          Navigates backward one item in the history list.
 void goForward()
          Navigates forward one item in the history list.
 void goHome()
          Navigates to the current home or start page.
 boolean isClosed()
          Returns true if the WebBrowser instance is closed and disposed.
 boolean isSilent()
          Return true if alert, confirmation and error dialogs are disabled else returns false.
 void navigate(java.lang.String location)
          Navigates to a resource identified by a URL or to a file identified by a full path.
 void navigate(java.lang.String location, java.lang.String postData)
          Navigates to a web resource specified by a HTTP URL with HTTP post data.
 void navigate(java.lang.String location, java.lang.String targetName, java.lang.String postData)
          Navigates to an entire web resource specified by a HTTP URL with HTTP post data into a specified window defined by targetName.
 void navigate(java.lang.String location, java.lang.String targetName, java.lang.String postData, java.lang.String headers)
          Navigates to an entire web resource specified by a HTTP URL with HTTP post data into a specified window defined by targetName.
 void refresh()
          Reloads the file that is currently displayed in the object.
 void removeBrowserWindowListener(BrowserWindowListener listener)
          Removes window listener.
 void removeDisposeListener(DisposeListener listener)
          Removes the listener so that it will not receive events when the current Browser instance is disposed.
 void removeNavigationListener(NavigationEventListener listener)
          Removes browser navigation event listener.
 void removeNewWindowListener(NewWindowEventListener listener)
          Removes new window listener.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Removes a specified property change listener.
 void removeStatusListener(StatusEventListener listener)
          Removes browser status event listener.
 void setAuthenticationHandler(AuthenticationHandler handler)
          Sets the specified browser authentication handler.
 void setContent(java.lang.String htmlContent)
          Sets new HTML content.
 void setCookie(java.lang.String url, Cookie cookie)
          Deprecated. Use the CookieManager.setCookie(URL url, Cookie cookie) or CookieManager.setCookies(URL url, Set cookies) methods instead.
 void setCookies(java.net.URL url, java.util.Set<Cookie> cookies)
          Creates a new cookies for the specified URL using WinINet API.
 void setDialogEventHandler(DialogEventHandler handler)
          Sets the listener interface for receiving show dialog events.
 void setEventHandler(WebBrowserEventsHandler handler)
          Sets browser event handler.
 void setHtmlDialogListener(HtmlDialogListener listener)
          Sets the specified HTML Dialog listener that allows receiving event when the HTML Dialog is shown and its document is loaded completely.
 void setHttpSecurityHandler(HttpSecurityHandler h)
          Sets the specified HTTP security handler that allows processing any security problems such as Invalid Certificate error, Invalid Certificate Name, Invalid Certificate Date, Moving from a non-SSL to an SSL connection because of a redirect or The redirection requires user confirmation problems.
 void setKeyFilter(KeyFilter keyFilter)
          Sets key filter.
 void setNewWindowHandler(NewWindowEventHandler newWindowHandler)
          Sets new window handler.
 void setParentBrowser(WebBrowser webBrowser)
          Deprecated. Will be removed because WebBrowser instance will receive parent automatically.
 void setProxy(ProxyConfiguration conf)
          Sets the specified proxy settings for the current WebBrowser control and all its children.
 void setScriptErrorListener(ScriptErrorListener listener)
          Setups javascript error listener for current page.
 void setSilent(boolean isSilent)
          Disables or enables alert, confirmation and error dialogs.
 void setZoomValue(int value)
           
 void stop()
          Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.
 void trackChildren()
          Starts to collect information about child object creation.
 WebBrowser waitChildCreation()
          Blocks execution until child is created since last trackChildren() call and returns this child.
 WebBrowser waitChildCreation(java.lang.Runnable operationThatCreatesChild)
          Executes operation specified in the parameter and returns when child created by the operation is opened.
 void waitReady()
          Causes a current thread to wait for the completion of the current operation in the browser.
 void waitReady(long timeout)
          Deprecated. Use the NavigationEventListener.entireDocumentCompleted event to make sure that the document is loaded completely.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeadlessBrowser

public HeadlessBrowser()
Creates Internet Explorer wrapper for automated testing.


HeadlessBrowser

public HeadlessBrowser(HeadlessBrowser parent)
Method Detail

getOptions

public BrowserOptions getOptions()

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Adds a new property change listener. The available property names are presented in the WebBrowser.Properties class.

Specified by:
addPropertyChangeListener in interface WebBrowser
Parameters:
propertyName - property name.
listener - listener instance.

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Removes a specified property change listener. The available property names are represented in the WebBrowser.Properties class.

Specified by:
removePropertyChangeListener in interface WebBrowser
Parameters:
propertyName - property name.
listener - listener instance.

getDocument

public org.w3c.dom.html.HTMLDocument getDocument()
Returns an instance of HTMLDocument that represents the HTML document currently loaded into the WebBrowser and provides access to the contents of the HTML Document Object Model (DOM).

Before receiving an instance of HTMLDocument make sure that the entire document is loaded completely. For this you can use the NavigationEventListener.entireDocumentCompleted(WebBrowser, String) event.

Specified by:
getDocument in interface WebBrowser
Returns:
The HTML document currently loaded into the WebBrowser. This instance supports all the required properties and methods to access the entire contents of the active HTML document.
Throws:
java.lang.IllegalStateException - when WebBrowser.waitReady() method isn't called after last call of WebBrowser.navigate() or WebBrowser.setContent() methods; or when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
WebBrowser.waitReady(), WebBrowser.navigate(String), WebBrowser.setContent(String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getParentBrowser

public WebBrowser getParentBrowser()
Returns the parent of the browser.

Specified by:
getParentBrowser in interface WebBrowser
Returns:
the parent of the browser or null if the browser not has the parent.
See Also:
Browser.getParentBrowser(), getParentBrowser(), IEAutomation.getParentBrowser()

setParentBrowser

public void setParentBrowser(WebBrowser webBrowser)
Deprecated. Will be removed because WebBrowser instance will receive parent automatically.

Sets the parent of the browser.

Specified by:
setParentBrowser in interface WebBrowser
Parameters:
webBrowser - the parent of the browser.

setContent

public void setContent(java.lang.String htmlContent)
Sets new HTML content.

Specified by:
setContent in interface WebBrowser
Parameters:
htmlContent - HTML content to set.
See Also:
WebBrowser.navigate(String), WebBrowser.navigate(String, String), WebBrowser.navigate(String, String, String), WebBrowser.getContent(), WebBrowser.getContent(boolean), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getContent

public java.lang.String getContent()
Returns the HTML content of a document, opened in a browser.

Specified by:
getContent in interface WebBrowser
Returns:
the HTML content of a document, opened in a browser.
See Also:
WebBrowser.setContent(String), WebBrowser.getContent(boolean), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getContent

public java.lang.String getContent(boolean original)
Description copied from interface: WebBrowser
Returns the string that represents HTML content of a currently loaded document in WebBrowser. To make sure that the document is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Specified by:
getContent in interface WebBrowser
Parameters:
original - if true then returns the original HTML content (like View Source command in context menu of Internet Explorer browser), otherwise this method returns the actual content of a document according to its DOM.
Returns:
the HTML content of a document, opened in a browser.
See Also:
WebBrowser.getContent(), WebBrowser.setContent(String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

navigate

public void navigate(java.lang.String location)
Navigates to a resource identified by a URL or to a file identified by a full path. The WebBrowser can browse to any location in the local file system, on the network, or on the World Wide Web.

This method is executes asynchronously. To make sure that required resource is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Specified by:
navigate in interface WebBrowser
Parameters:
location - the URL of the resource to display or the full path to the file location. The parameter cannot be null.
Throws:
java.lang.IllegalArgumentException - when location parameter is null.
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
navigate(String, String), navigate(String, String, String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

navigate

public void navigate(java.lang.String location,
                     java.lang.String postData)
Navigates to a web resource specified by a HTTP URL with HTTP post data. The WebBrowser can browse to any location in the local file system, on the network, or on the World Wide Web.

This method is executes asynchronously. To make sure that required resource is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Specified by:
navigate in interface WebBrowser
Parameters:
location - the URL of the resource to display or the full path to the file location. The parameter cannot be null.
postData - HTTP post data (for example, "name=Alex&product=Pizza"), can be null.
Throws:
java.lang.IllegalArgumentException - when location parameter is null.
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
navigate(String), navigate(String, String, String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

navigate

public void navigate(java.lang.String location,
                     java.lang.String targetName,
                     java.lang.String postData)
Navigates to an entire web resource specified by a HTTP URL with HTTP post data into a specified window defined by targetName.

This method is executes asynchronously. To make sure that required resource is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Specified by:
navigate in interface WebBrowser
Parameters:
location - the URL of the resource to display or the full path to the file location. The parameter cannot be null.
targetName - The string that contains the name of the frame in which to display the resource. The possible values for this parameter are.
  • _blank - Load the link into a new unnamed window.
  • _parent - Load the link into the immediate parent of the document the link is in.
  • _self - Load the link into the same window the link was clicked in.
  • _top - Load the link into the full body of the current window.
  • WindowName - A named HTML frame. If no frame or window exists that matches the specified target name, a new window is opened for the specified link.
postData - HTTP post data (for example, "name=Alex&product=Pizza").
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
navigate(String), navigate(String, String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

navigate

public void navigate(java.lang.String location,
                     java.lang.String targetName,
                     java.lang.String postData,
                     java.lang.String headers)
Description copied from interface: WebBrowser
Navigates to an entire web resource specified by a HTTP URL with HTTP post data into a specified window defined by targetName.

This method is executes asynchronously. To make sure that required resource is loaded completely use the NavigationEventListener.entireDocumentCompleted event.

Specified by:
navigate in interface WebBrowser
Parameters:
location - the URL of the resource to display or the full path to the file location. The parameter cannot be null.
targetName - The string that contains the name of the frame in which to display the resource. The possible values for this parameter are.
  • _blank - Load the link into a new unnamed window.
  • _parent - Load the link into the immediate parent of the document the link is in.
  • _self - Load the link into the same window the link was clicked in.
  • _top - Load the link into the full body of the current window.
  • WindowName - A named HTML frame. If no frame or window exists that matches the specified target name, a new window is opened for the specified link.
postData - HTTP post data (for example, "name=Alex&product=Pizza").
headers - The string that contains additional HTTP headers to send to the server. These headers are added to the default Windows Internet Explorer headers. For example, headers can specify the action required of the server, the type of data being passed to the server, or a status code. This parameter is ignored if the URL is not an HTTP (or HTTPS) URL.
See Also:
WebBrowser.navigate(String), WebBrowser.navigate(String, String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

getLocationURL

public java.lang.String getLocationURL()
Returns the string that represents a URL of the resource that WebBrowser component is currently displayed.

If the resource is a folder or file on the network or local computer, the name is the full path of the folder or file in the Universal Naming Convention (UNC) format.

If this method is called before the first navigation is complete, the WebBrowser returns an empty string.

Specified by:
getLocationURL in interface WebBrowser
Returns:
location the string that represents a URL of a currently loaded resource
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

goForward

public void goForward()
Navigates forward one item in the history list.

During a browsing session, the WebBrowser control maintain a history list of all Web sites visited during a session. Use the StatusEventListener.forwardButtonEnabled event to check the enabled state of forward navigation.

To manage WebBrowser's history use the BrowserHistory class.

Specified by:
goForward in interface WebBrowser
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
WebBrowser.goBack(), WebBrowser.goHome(), BrowserHistory

goBack

public void goBack()
Navigates backward one item in the history list.

During a browsing session, the WebBrowser control maintain a history list of all Web sites visited during a session. Use the StatusEventListener.backButtonEnabled event to check the enabled state of back navigation.

To manage WebBrowser's history use the BrowserHistory class.

Specified by:
goBack in interface WebBrowser
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
WebBrowser.goForward(), WebBrowser.goHome(), BrowserHistory

goHome

public void goHome()
Navigates to the current home or start page.

The user can indicate the URL to use for the home page from the Internet Options dialog box, which is accessible from the Tools menu of Windows Internet Explorer, or in the Control Panel.

Specified by:
goHome in interface WebBrowser
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
WebBrowser.goForward(), WebBrowser.goBack()

stop

public void stop()
Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.

Specified by:
stop in interface WebBrowser
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
refresh(), navigate(String), NavigationEventListener.entireDocumentCompleted(WebBrowser, String)

refresh

public void refresh()
Reloads the file that is currently displayed in the object.

Specified by:
refresh in interface WebBrowser

execute

public void execute(BrowserCommand command)
Executes specified command.

Specified by:
execute in interface WebBrowser
Parameters:
command - browser command.
See Also:
PrintCommand, PrintPreviewCommand, SaveAsCommand

getReadyState

public ReadyState getReadyState()
Returns the current ReadyState of the browser.

Specified by:
getReadyState in interface WebBrowser
Returns:
the current state of the browser.

executeScript

public java.lang.Object executeScript(java.lang.String javaScript)
Executes specified JavaScript code in a currently opened document.

Specified by:
executeScript in interface WebBrowser
Parameters:
javaScript - JavaScript to execute.
Returns:
the result of JavaScript execution, if any.

getBrowserPeer

public java.lang.Object getBrowserPeer()
Returns an instance of the native web browser peer.

Specified by:
getBrowserPeer in interface WebBrowser
Returns:
native peer object.
Throws:
java.lang.IllegalStateException - if the passed browser does not have a native peer.

waitReady

public void waitReady()
Causes a current thread to wait for the completion of the current operation in the browser.

Important: successful call of this method guaranties that you can get DOM document of loaded page. Please see typical usage of this method in the code below:

     // navigate to Google page
     browser.navigate("google.com");
 

// wait until page completely loaded browser.waitReady();

// DOM document is available Document document = browser.getDocument();

If you miss WebBrowser.waitReady() call after navigation call then IllegalStateException is thrown in WebBrowser.getDocument() call.

Specified by:
waitReady in interface WebBrowser
See Also:
WebBrowser.navigate(String), WebBrowser.setContent(String), WebBrowser.getDocument()

waitReady

public void waitReady(long timeout)
Deprecated. Use the NavigationEventListener.entireDocumentCompleted event to make sure that the document is loaded completely.

Causes a current thread to wait for the completion of a current operation in the browser for a specified amount of milliseconds.

Specified by:
waitReady in interface WebBrowser
Parameters:
timeout - the number of milliseconds to wait.

addNavigationListener

public void addNavigationListener(NavigationEventListener listener)
Adds browser navigation event listener.

Specified by:
addNavigationListener in interface WebBrowser
Parameters:
listener - browser event listener.

addStatusListener

public void addStatusListener(StatusEventListener listener)
Adds browser status event listener.

Specified by:
addStatusListener in interface WebBrowser
Parameters:
listener - browser event listener.

getNavigationListeners

public java.util.List<NavigationEventListener> getNavigationListeners()
Returns browser navigation event listeners.

Specified by:
getNavigationListeners in interface WebBrowser
Returns:
list of browser event listeners

getStatusListeners

public java.util.List<StatusEventListener> getStatusListeners()
Returns browser status event listeners.

Specified by:
getStatusListeners in interface WebBrowser
Returns:
list of browser event listeners

removeNavigationListener

public void removeNavigationListener(NavigationEventListener listener)
Removes browser navigation event listener.

Specified by:
removeNavigationListener in interface WebBrowser
Parameters:
listener - browser event listener.

removeStatusListener

public void removeStatusListener(StatusEventListener listener)
Removes browser status event listener.

Specified by:
removeStatusListener in interface WebBrowser
Parameters:
listener - browser event listener.

getEventHandler

public WebBrowserEventsHandler getEventHandler()
Returns browser event handler.

Specified by:
getEventHandler in interface WebBrowser
Returns:
browser event handler

setAuthenticationHandler

public void setAuthenticationHandler(AuthenticationHandler handler)
Sets the specified browser authentication handler. The authentication handler allows handling the authenticate events from the browser object. Currently supported the basic, digest and NTLM authentication schemes.

Specified by:
setAuthenticationHandler in interface WebBrowser
Parameters:
handler - the authentication handler
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
getAuthenticationHandler()

getAuthenticationHandler

public AuthenticationHandler getAuthenticationHandler()
Returns the current browser authentication handler or null if it's was not specified. The authentication handler allows handling the authenticate events from the browser object. Currently supported the basic, digest and NTLM authentication schemes.

Specified by:
getAuthenticationHandler in interface WebBrowser
Returns:
the current browser authentication handler or null.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
setAuthenticationHandler(AuthenticationHandler)

setEventHandler

public void setEventHandler(WebBrowserEventsHandler handler)
Sets browser event handler.

Specified by:
setEventHandler in interface WebBrowser
Parameters:
handler - event handler

setScriptErrorListener

public void setScriptErrorListener(ScriptErrorListener listener)
Setups javascript error listener for current page.

Specified by:
setScriptErrorListener in interface WebBrowser
Parameters:
listener - javascript error listener

getScriptErrorListener

public ScriptErrorListener getScriptErrorListener()
Returns script error listener for current page.

Specified by:
getScriptErrorListener in interface WebBrowser
Returns:
script error listener

close

public void close()
Closes browser instance.

Note: Prior to 1.4, the non-daemon helper threads were never terminated. Starting with 1.4, the behavior has changed as a result of the fix for 4030718. With the current implementation, AWT terminates all its helper threads allowing the application to exit cleanly when the following three conditions are true:

The JExplorer's headless mode uses the Swing component like JWindow to hold an application durings its execution. To exit cleanly without calling System.exit you must to call this method for each instance in your application.

Specified by:
close in interface WebBrowser
See Also:
WebBrowser.isClosed()

isClosed

public boolean isClosed()
Returns true if the WebBrowser instance is closed and disposed. Use this method when you need to make sure that the WebBrowser instance is alive and can can invoke its methods.

Specified by:
isClosed in interface WebBrowser
Returns:
true if the WebBrowser instance is closed and disposed.
See Also:
close()

setSilent

public void setSilent(boolean isSilent)
Disables or enables alert, confirmation and error dialogs.

Specified by:
setSilent in interface WebBrowser
Parameters:
isSilent - if true then enter to silent mode else leave silent mode.

isSilent

public boolean isSilent()
Return true if alert, confirmation and error dialogs are disabled else returns false.

Specified by:
isSilent in interface WebBrowser
Returns:
true if in silent mode else returns false.

getOleMessageLoop

public com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
Return browser OLE message loop.

Specified by:
getOleMessageLoop in interface WebBrowser
Returns:
browser OLE message loop.

setProxy

public void setProxy(ProxyConfiguration conf)
Sets the specified proxy settings for the current WebBrowser control and all its children. These settings will be applied only for the current WebBrowser instance and they will not affect on the system local area network (LAN) proxy settings.

In order to change the system local area network (LAN) proxy settings please use the Browsers.setProxy(ProxyConfiguration) method.

Specified by:
setProxy in interface WebBrowser
Parameters:
conf - the proxy settings. This parameter cannot be null.
Throws:
java.lang.IllegalStateException - when the passed browser does not have a native peer or WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
getProxy()

getProxy

public ProxyConfiguration getProxy()
Returns the proxy settings for the current WebBrowser control.

Specified by:
getProxy in interface WebBrowser
Returns:
the proxy settings for the current WebBrowser control.
Throws:
java.lang.IllegalStateException - when the passed browser does not have a native peer or WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
setProxy(ProxyConfiguration)

getCookies

public java.util.Set<Cookie> getCookies(java.net.URL url)
Description copied from interface: WebBrowser
Returns cookies, that are associated with the specified URL.

It checks in the windows\cookies directory for persistent cookies that have an expiration date set sometime in the future.

It also searches memory for any session cookies, that is, cookies that do not have an expiration date that were created in the same process by CookieManager.setCookie(), because these cookies are not written to any files. Rules for creating cookie files are internal to the system and can change in the future.

Note: The method does not return cookies that the server marked as non-scriptable with the "HttpOnly" attribute in the Set-Cookie header.

Specified by:
getCookies in interface WebBrowser
Parameters:
url - specifies an URL.
Returns:
cookies, that are associated with the specified URL.

setCookies

public void setCookies(java.net.URL url,
                       java.util.Set<Cookie> cookies)
Description copied from interface: WebBrowser
Creates a new cookies for the specified URL using WinINet API.

Cookies created by this method without an expiration date are stored in memory and are available only in the same process that created them. Cookies that include an expiration date are stored in the windows\cookies directory.

Specified by:
setCookies in interface WebBrowser
Parameters:
url - specifies an URL, a new cookie will be associated with.
cookies - the collection of Cookie objects.

setHttpSecurityHandler

public void setHttpSecurityHandler(HttpSecurityHandler h)
Sets the specified HTTP security handler that allows processing any security problems such as Invalid Certificate error, Invalid Certificate Name, Invalid Certificate Date, Moving from a non-SSL to an SSL connection because of a redirect or The redirection requires user confirmation problems.

Specified by:
setHttpSecurityHandler in interface WebBrowser
Parameters:
h - the specified HTTP security handler.
Throws:
java.lang.IllegalStateException - when the passed browser does not have a native peer or WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
getHttpSecurityHandler()

getHttpSecurityHandler

public HttpSecurityHandler getHttpSecurityHandler()
Returns http security handler that allows processing any security problems or null if it's not present. By default this method always returns null and all security problems are processing by default Internet Explorer security handler.

Specified by:
getHttpSecurityHandler in interface WebBrowser
Returns:
the current http security handler that allows processing any security problems or null if it's not present
Throws:
java.lang.IllegalStateException - when the passed browser does not have a native peer or WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
setHttpSecurityHandler(com.jniwrapper.win32.ie.event.HttpSecurityHandler)

addDisposeListener

public void addDisposeListener(DisposeListener listener)
Registers the listener for the current Browser instance that will receive events when the current Browser instance is disposed.

Specified by:
addDisposeListener in interface WebBrowser
Parameters:
listener - the listener to receive browser dispose events.

removeDisposeListener

public void removeDisposeListener(DisposeListener listener)
Removes the listener so that it will not receive events when the current Browser instance is disposed.

Specified by:
removeDisposeListener in interface WebBrowser
Parameters:
listener - the listener to remove.

getDisposeListeners

public DisposeListener[] getDisposeListeners()
Returns an array of all registered listeners for the current Browser instance.

Specified by:
getDisposeListeners in interface WebBrowser
Returns:
an array of all registered listeners for the current Browser instance.

setDialogEventHandler

public void setDialogEventHandler(DialogEventHandler handler)
Sets the listener interface for receiving show dialog events. This method allows specifying the handler for processing events when the JavaScript Alert, Confirmation or Error dialog should be shown.

Specified by:
setDialogEventHandler in interface WebBrowser
Parameters:
handler - dialog event handler
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
getDialogEventHandler(), setSilent(boolean), isSilent()

getDialogEventHandler

public DialogEventHandler getDialogEventHandler()
Returns the dialog events handler or null if it's was not specified.

By default this method returns the HeadlessBrowserDialogEventHandler implementation.

Specified by:
getDialogEventHandler in interface WebBrowser
Returns:
the dialog events handler or null if it's was not specified.
Throws:
java.lang.IllegalStateException - when WebBrowser component was disposed by invoking WebBrowser.close() method or for some unknown reasons.
See Also:
setDialogEventHandler(DialogEventHandler), setSilent(boolean), isSilent()

setNewWindowHandler

public void setNewWindowHandler(NewWindowEventHandler newWindowHandler)
Sets new window handler.

Specified by:
setNewWindowHandler in interface WebBrowser
Parameters:
newWindowHandler - new window handler

getNewWindowHandler

public NewWindowEventHandler getNewWindowHandler()
Returns new window handler.

Specified by:
getNewWindowHandler in interface WebBrowser
Returns:
new window handler

addNewWindowListener

public void addNewWindowListener(NewWindowEventListener listener)
Adds new window listener.

Specified by:
addNewWindowListener in interface WebBrowser
Parameters:
listener - new window listener

removeNewWindowListener

public void removeNewWindowListener(NewWindowEventListener listener)
Removes new window listener.

Specified by:
removeNewWindowListener in interface WebBrowser
Parameters:
listener - new window listener

getNewWindowListeners

public java.util.List<NewWindowEventListener> getNewWindowListeners()
Returns new window listeners.

Specified by:
getNewWindowListeners in interface WebBrowser
Returns:
new window listeners

trackChildren

public void trackChildren()
Starts to collect information about child object creation.

Specified by:
trackChildren in interface ParentWindow

getRecentChild

public WebBrowser getRecentChild()
Returns recent created child object since last trackChildren() method call.

Specified by:
getRecentChild in interface ParentWindow
Returns:
recent opened child window after the last trackChildren() method call. If there isn't opened windows after this call then returns null.

waitChildCreation

public WebBrowser waitChildCreation()
Blocks execution until child is created since last trackChildren() call and returns this child.

In other words, this method waits until getRecentChild() call returns non-null object.

Specified by:
waitChildCreation in interface ParentWindow
Returns:
recent created child

waitChildCreation

public WebBrowser waitChildCreation(java.lang.Runnable operationThatCreatesChild)
Executes operation specified in the parameter and returns when child created by the operation is opened.

Specified by:
waitChildCreation in interface ParentWindow
Parameters:
operationThatCreatesChild - operation
Returns:
child created by the operation

setKeyFilter

public void setKeyFilter(KeyFilter keyFilter)
Sets key filter.

Specified by:
setKeyFilter in interface WebBrowser
Parameters:
keyFilter - key filter

getKeyFilter

public KeyFilter getKeyFilter()
Returns key filter.

Specified by:
getKeyFilter in interface WebBrowser
Returns:
key filter

setCookie

public void setCookie(java.lang.String url,
                      Cookie cookie)
Deprecated. Use the CookieManager.setCookie(URL url, Cookie cookie) or CookieManager.setCookies(URL url, Set cookies) methods instead.

Creates a new cookie for the specified URL using WinINet API. This is an analogue of the InternetSetCookie native function.

Specified by:
setCookie in interface WebBrowser
Parameters:
url - specifies an URL, a new cookie will be associated with.
cookie - specifies a new cookie.

getCookies

public java.util.Set<Cookie> getCookies(java.lang.String url)
Deprecated. Use the CookieManager.getCookies(URL url) method instead.

Returns cookies, that are associated with the specified URL. This is an analogue of the InternetGetCookie native function.

Specified by:
getCookies in interface WebBrowser
Parameters:
url - specifies an URL.
Returns:
cookies, that are associated with the specified URL.

setHtmlDialogListener

public void setHtmlDialogListener(HtmlDialogListener listener)
Sets the specified HTML Dialog listener that allows receiving event when the HTML Dialog is shown and its document is loaded completely. The HTML Dialog can be opened using the window.showModalDialog and window.showModelessDialog JavaScript functions.

Parameters:
listener - the specified HTML Dialog listener.
See Also:
getHtmlDialogListener()

getHtmlDialogListener

public HtmlDialogListener getHtmlDialogListener()
Returns the current HTML Dialog listener or null if it's not registered.

Returns:
the current HTML Dialog listener or null if it's not registered.
See Also:
setHtmlDialogListener(com.jniwrapper.win32.ie.event.HtmlDialogListener)

getProperties

public WebBrowser.Properties getProperties()
Returns extended browser properties.

Specified by:
getProperties in interface WebBrowser
Returns:
extended browser properties.

addBrowserWindowListener

public void addBrowserWindowListener(BrowserWindowListener listener)
Description copied from interface: WebBrowser
Adds window listener.

Specified by:
addBrowserWindowListener in interface WebBrowser
Parameters:
listener - the window listener

removeBrowserWindowListener

public void removeBrowserWindowListener(BrowserWindowListener listener)
Description copied from interface: WebBrowser
Removes window listener.

Specified by:
removeBrowserWindowListener in interface WebBrowser
Parameters:
listener - the window listener

setZoomValue

public void setZoomValue(int value)
Specified by:
setZoomValue in interface WebBrowser

getZoomValue

public int getZoomValue()
Specified by:
getZoomValue in interface WebBrowser