|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jniwrapper.win32.ie.HeadlessBrowser
This class is the windowless implementation of WebBrowser iterface,
specially designed for such operations that do not require a Java component.
| Nested Class Summary | |
static class |
HeadlessBrowser.ComServerParameters
|
| Nested classes inherited from class com.jniwrapper.win32.ie.WebBrowser |
WebBrowser.Properties |
| Constructor Summary | |
HeadlessBrowser()
Creates Internet Explorer wrapper for automated testing. |
|
HeadlessBrowser(HeadlessBrowser.ComServerParameters parameters)
Creates Internet Explorer wrapper for automated testing. |
|
HeadlessBrowser(HeadlessBrowser.ComServerParameters parameters,
com.jniwrapper.win32.automation.OleMessageLoop oleMessageLoop)
Creates Internet Explorer wrapper for automated testing. |
|
HeadlessBrowser(HeadlessBrowser.ComServerParameters parameters,
com.jniwrapper.win32.automation.OleMessageLoop oleMessageLoop,
java.lang.String pathKey)
Creates Internet Explorer wrapper for automated testing. |
|
| Method Summary | |
void |
addBrowserWindowListener(BrowserWindowListener listener)
Adds window listener. |
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. |
static HeadlessBrowser |
createLightweightBrowser()
Creates browser without event listening that uses InternetExplorer component. |
void |
execute(BrowserCommand command)
Executes specified command. |
java.lang.Object |
executeScript(java.lang.String javaScript)
Executes specified JavaScript code in a currently opened document. |
void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
|
AuthenticateHandler |
getAuthenticateHandler()
Returns browser authenticate handler. |
java.lang.Object |
getBrowserPeer()
Returns an instance of the native web browser peer. |
BrowserWindowListener[] |
getBrowserWindowListeners()
Returns an array of window listeners. |
java.lang.String |
getContent()
Returns the HTML content of a document, opened in a browser. |
java.util.Set |
getCookies(java.lang.String url)
Returns cookies, that are associated with the specified URL. |
DialogEventHandler |
getDialogEventHandler()
Gets dialog event handler. |
HTMLDocument |
getDocument()
Returns DOM document for page loaded into the browser. |
WebBrowserEventsHandler |
getEventHandler()
Returns browser event handler. |
KeyFilter |
getKeyFilter()
Returns key filter. |
java.lang.String |
getLocationURL()
Returns the URL of the resource that Internet Explorer is currently displaying. |
java.util.List |
getNavigationListeners()
Returns browser navigation event listeners. |
NewWindowEventHandler |
getNewWindowHandler()
Returns new window handler. |
java.util.List |
getNewWindowListeners()
Returns new window listeners. |
com.jniwrapper.win32.automation.OleMessageLoop |
getOleMessageLoop()
Return browser OLE message loop. |
WebBrowser |
getParentBrowser()
Returns the parent of the browser. |
WebBrowser.Properties |
getProperties()
Returns extended browser properties. |
ReadyState |
getReadyState()
Returns the current ReadyState of the browser. |
WebBrowser |
getRecentChild()
Returns recent created child object since last trackChildren() method call. |
java.awt.Image |
getScreenShot(boolean wholePage)
|
ScriptErrorListener |
getScriptErrorListener()
Returns script error listener for current page. |
java.util.List |
getStatusListeners()
Returns browser status event listeners. |
java.lang.String |
getStatusText()
Returns the status text of the browser. |
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 home page. |
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 specified by a URL or to the file identified by a full path. |
void |
navigate(java.lang.String location,
java.lang.String postData)
Navigates to a resource specified by a HTTP URL. |
void |
navigate(java.lang.String location,
java.lang.String targetName,
java.lang.String postData)
Navigates the browser to a location that might not be able to be expressed as a URL, such as a pointer to an item identifier list (PIDL) for an entity in the Microsoft Windows shell namespace. |
void |
refresh()
Reloads the file that is currently displayed in the object. |
void |
removeBrowserWindowListener(BrowserWindowListener listener)
Removes window listener. |
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 |
setAuthenticateHandler(AuthenticateHandler handler)
Sets browser authenticate handler. |
void |
setContent(java.lang.String htmlContent)
Sets new HTML content. |
void |
setCookie(java.lang.String url,
Cookie cookie)
Creates a new cookie for the specified URL using WinINet API. |
void |
setDialogEventHandler(DialogEventHandler handler)
Sets dialog event handler. |
void |
setEventHandler(WebBrowserEventsHandler handler)
Sets browser event handler. |
void |
setKeyFilter(KeyFilter keyFilter)
Sets key filter. |
void |
setNewWindowHandler(NewWindowEventHandler newWindowHandler)
Sets new window handler. |
void |
setParentBrowser(WebBrowser webBrowser)
Sets the parent of the browser. |
void |
setScriptErrorListener(ScriptErrorListener listener)
Setups javascript error listener for current page. |
void |
setSilent(boolean isSilent)
Disables or enables alert, confirmation and error dialogs. |
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)
Causes a current thread to wait for the completion of a current operation in the browser for a specified amount of milliseconds. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public HeadlessBrowser()
public HeadlessBrowser(HeadlessBrowser.ComServerParameters parameters)
public HeadlessBrowser(HeadlessBrowser.ComServerParameters parameters,
com.jniwrapper.win32.automation.OleMessageLoop oleMessageLoop)
oleMessageLoop - the browser will be created in this message loop. May be null
public HeadlessBrowser(HeadlessBrowser.ComServerParameters parameters,
com.jniwrapper.win32.automation.OleMessageLoop oleMessageLoop,
java.lang.String pathKey)
oleMessageLoop - oleMessageLoop the browser will be created in this message loop. May be nullpathKey - the registry subkey string where the host stores its registry settings| Method Detail |
public java.lang.String getStatusText()
getStatusText in interface WebBrowser
public void addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
WebBrowser.Properties class.
addPropertyChangeListener in interface WebBrowserpropertyName - property name.listener - listener instance.
public void removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
WebBrowser.Properties class.
removePropertyChangeListener in interface WebBrowserpropertyName - property name.listener - listener instance.public HTMLDocument getDocument()
getDocument in interface WebBrowserjava.lang.IllegalStateException - if WebBrowser.waitReady() method isn't called after last call of WebBrowser.navigate() or
WebBrowser.setContent() methods.WebBrowser.waitReady(),
WebBrowser.navigate(String),
WebBrowser.setContent(String)public WebBrowser getParentBrowser()
WebBrowser
getParentBrowser in interface WebBrowsernull if the browser not has the parent.public void setParentBrowser(WebBrowser webBrowser)
WebBrowser
setParentBrowser in interface WebBrowserwebBrowser - the parent of the browser.public void setContent(java.lang.String htmlContent)
setContent in interface WebBrowserhtmlContent - HTML content to set.public java.lang.String getContent()
getContent in interface WebBrowserpublic void navigate(java.lang.String location)
navigate in interface WebBrowserlocation - URL to navigate to.
public void navigate(java.lang.String location,
java.lang.String postData)
navigate in interface WebBrowserlocation - URL to navigate to.postData - HTTP post data (for example, "name=Alex&product=Pizza")
public void navigate(java.lang.String location,
java.lang.String targetName,
java.lang.String postData)
navigate in interface WebBrowserlocation - URL to navigate to.targetName - string that contains the name of the frame in which to display the resource.postData - HTTP post data (for example, "name=Alex&product=Pizza").public java.lang.String getLocationURL()
getLocationURL in interface WebBrowserpublic void goForward()
goForward in interface WebBrowserpublic void goBack()
goBack in interface WebBrowserpublic void goHome()
goHome in interface WebBrowserpublic void stop()
stop in interface WebBrowserpublic void refresh()
refresh in interface WebBrowserpublic void execute(BrowserCommand command)
execute in interface WebBrowsercommand - browser command.
public void firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
public ReadyState getReadyState()
ReadyState of the browser.
getReadyState in interface WebBrowserpublic java.lang.Object executeScript(java.lang.String javaScript)
executeScript in interface WebBrowserjavaScript - JavaScript to execute.
public java.lang.Object getBrowserPeer()
getBrowserPeer in interface WebBrowserjava.lang.IllegalStateException - if the passed browser does not have a native peer.public void waitReady()
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();
WebBrowser.waitReady() call after navigation call
then IllegalStateException is thrown in WebBrowser.getDocument() call.
waitReady in interface WebBrowserWebBrowser.navigate(String),
WebBrowser.setContent(String),
WebBrowser.getDocument()public void waitReady(long timeout)
waitReady in interface WebBrowsertimeout - the number of milliseconds to wait.public void addNavigationListener(NavigationEventListener listener)
addNavigationListener in interface WebBrowserlistener - browser event listener.public void addStatusListener(StatusEventListener listener)
addStatusListener in interface WebBrowserlistener - browser event listener.public java.util.List getNavigationListeners()
getNavigationListeners in interface WebBrowserpublic java.util.List getStatusListeners()
getStatusListeners in interface WebBrowserpublic void removeNavigationListener(NavigationEventListener listener)
removeNavigationListener in interface WebBrowserlistener - browser event listener.public void removeStatusListener(StatusEventListener listener)
removeStatusListener in interface WebBrowserlistener - browser event listener.public WebBrowserEventsHandler getEventHandler()
getEventHandler in interface WebBrowserpublic void setAuthenticateHandler(AuthenticateHandler handler)
setAuthenticateHandler in interface WebBrowserhandler - authenticate handlerpublic AuthenticateHandler getAuthenticateHandler()
getAuthenticateHandler in interface WebBrowserpublic void setEventHandler(WebBrowserEventsHandler handler)
setEventHandler in interface WebBrowserhandler - event handlerpublic void setScriptErrorListener(ScriptErrorListener listener)
setScriptErrorListener in interface WebBrowserlistener - javascript error listenerpublic ScriptErrorListener getScriptErrorListener()
getScriptErrorListener in interface WebBrowserpublic void close()
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:
System.exit you must to
call this method for each instance in your application.
close in interface WebBrowserpublic void setSilent(boolean isSilent)
setSilent in interface WebBrowserisSilent - if true then enter to silent mode else leave silent mode.public boolean isSilent()
isSilent in interface WebBrowserpublic com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
getOleMessageLoop in interface SingleThreadedComponentpublic DialogEventHandler getDialogEventHandler()
getDialogEventHandler in interface WebBrowserpublic void setDialogEventHandler(DialogEventHandler handler)
setDialogEventHandler in interface WebBrowserhandler - dialog event handlerpublic void setNewWindowHandler(NewWindowEventHandler newWindowHandler)
setNewWindowHandler in interface WebBrowsernewWindowHandler - new window handlerpublic NewWindowEventHandler getNewWindowHandler()
getNewWindowHandler in interface WebBrowserpublic void addNewWindowListener(NewWindowEventListener listener)
addNewWindowListener in interface WebBrowserlistener - new window listenerpublic void removeNewWindowListener(NewWindowEventListener listener)
removeNewWindowListener in interface WebBrowserlistener - new window listenerpublic java.util.List getNewWindowListeners()
getNewWindowListeners in interface WebBrowserpublic void trackChildren()
ParentWindow
trackChildren in interface ParentWindowpublic WebBrowser getRecentChild()
ParentWindowtrackChildren() method call.
getRecentChild in interface ParentWindowtrackChildren() method call.
If there isn't opened windows after this call then returns null.public WebBrowser waitChildCreation()
ParentWindowtrackChildren() call and returns this child.
In other words, this method waits until getRecentChild() call returns non-null object.
waitChildCreation in interface ParentWindowpublic WebBrowser waitChildCreation(java.lang.Runnable operationThatCreatesChild)
ParentWindow
waitChildCreation in interface ParentWindowoperationThatCreatesChild - operation
public void setKeyFilter(KeyFilter keyFilter)
WebBrowser
setKeyFilter in interface WebBrowserkeyFilter - key filterpublic KeyFilter getKeyFilter()
WebBrowser
getKeyFilter in interface WebBrowser
public void setCookie(java.lang.String url,
Cookie cookie)
InternetSetCookie native function.
setCookie in interface WebBrowserurl - specifies an URL, a new cookie will be associated with.cookie - specifies a new cookie.public java.util.Set getCookies(java.lang.String url)
InternetGetCookie native function.
getCookies in interface WebBrowserurl - specifies an URL.
public static HeadlessBrowser createLightweightBrowser()
public WebBrowser.Properties getProperties()
WebBrowser
getProperties in interface WebBrowserpublic void addBrowserWindowListener(BrowserWindowListener listener)
WebBrowser
addBrowserWindowListener in interface WebBrowserlistener - the window listenerpublic void removeBrowserWindowListener(BrowserWindowListener listener)
WebBrowser
removeBrowserWindowListener in interface WebBrowserlistener - the window listenerpublic BrowserWindowListener[] getBrowserWindowListeners()
WebBrowser
getBrowserWindowListeners in interface WebBrowserpublic java.awt.Image getScreenShot(boolean wholePage)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||