org.mozilla.mcp
Class MCP

java.lang.Object
  extended by org.mozilla.mcp.MCP

public class MCP
extends java.lang.Object

The main class for the Mozilla Control Program. Please see the package description for an overview.

Author:
edburns

Constructor Summary
MCP()
          Creates a new instance of MCP
 
Method Summary
 void addAjaxListener(AjaxListener listener)
          Add the argument AjaxListener to this MCP instance.
 void addKeyListener(java.awt.event.KeyListener listener)
          Add the argument KeyListener to the Canvas for this MCP instance.
 void addMouseListener(java.awt.event.MouseListener listener)
          Add the argument MouseListener to the Canvas for this MCP instance.
 void appendKeyCodeToCurrentElementText(int keyCode)
           
 void blockingClickElement(org.w3c.dom.Element element)
          Find the DOM element within the current page matching the argument id using findElement(java.lang.String).
 void blockingClickElement(java.lang.String idOrName)
          Find the DOM element within the current page matching the argument id using findElement(java.lang.String).
 void blockingLoad(java.lang.String url)
          Load the url, blocking until the load has completed.
 void clickElement(org.w3c.dom.Element element)
          Find the DOM element within the current page matching the argument id using findElement(java.lang.String).
 void clickElement(java.lang.String id)
          Find the DOM element within the current page matching the argument id using findElement(java.lang.String).
 void deleteBrowserControl()
          Make invisible, and delete the BrowserControl instance for this MCP instance.
 org.w3c.dom.Element findElement(java.lang.String id)
          Return the DOM Element with the given id or name.
 org.w3c.dom.Element findElementById(java.lang.String id)
           
 boolean findInPage(java.lang.String toFind)
          Return true if and only if the argument toFind occurs within the current page.
 void focusElement(org.w3c.dom.Element toFocus)
           
 java.util.List<org.w3c.dom.Element> getAnchors()
          Return a List of DOM Element instances that are HTML anchors that are present in the document.
 java.util.List<org.w3c.dom.Element> getAnchors(java.lang.String id)
          Given an argument id, return a List of DOM Element instances that are HTML anchors that are direct or indirect children of the element with that id.
 BrowserControl getBrowserControl()
          Return the Webclient BrowserControl instance used by this MCP instance.
 java.util.List<org.w3c.dom.Element> getChildElementsWithTagName(org.w3c.dom.Element root, java.lang.String tagName)
          Return a List of DOM Element instances whose tagName attribute is equal to the argument tagName.
 java.util.List<org.w3c.dom.Element> getChildElementsWithTagName(java.lang.String id, java.lang.String tagName)
          Return a List of DOM Element instances whose tagName attribute is equal to the argument tagName.
 java.awt.Frame getRealizedVisibleBrowserWindow()
          Return the realized and visible java.awt.Frame containing the actual browser window.
 long getTimeout()
          Return the number of milliseconds that must elapse before the TimeoutHandler is called.
 TimeoutHandler getTimeoutHandler()
          Return the currently installed TimeoutHandler, if any.
 long getTimeoutWaitInterval()
          Return the number of milliseconds to wait between timeout checks.
 void removeAjaxListener(AjaxListener listener)
          Remove the argument AjaxListener to this MCP instance.
 void removeKeyListener(java.awt.event.KeyListener listener)
          Remove the argument KeyListener from the Canvas for this MCP instance.
 void removeMouseListener(java.awt.event.MouseListener listener)
          Remove the argument MouseListener from the Canvas for this MCP instance.
 void setAppData(java.lang.String absolutePathToNativeBrowserBinDir)
           
 void setBounds(int x, int y, int width, int height)
           
 void setTimeout(long Timeout)
          Set the number of milliseconds that must elapse before the TimeoutHandler is called, if such an instance has been installed via a previous call to @setTimeoutHandler.
 void setTimeoutHandler(TimeoutHandler timeoutHandler)
          Install an instance of TimeoutHandler that will be used for all subsequent browser interactions (clicks, loads, Ajax transactions, etc).
 void setTimeoutWaitInterval(long waitInterval)
          Set the number of milliseconds to wait between timeout checks.
 boolean waitUntilConditionMet(Condition condition)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCP

public MCP()
Creates a new instance of MCP

Method Detail

setAppData

public void setAppData(java.lang.String absolutePathToNativeBrowserBinDir)
                throws java.io.FileNotFoundException,
                       java.lang.ClassNotFoundException
Throws:
java.io.FileNotFoundException
java.lang.ClassNotFoundException

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)

addAjaxListener

public void addAjaxListener(AjaxListener listener)

Add the argument AjaxListener to this MCP instance.


removeAjaxListener

public void removeAjaxListener(AjaxListener listener)

Remove the argument AjaxListener to this MCP instance.


addMouseListener

public void addMouseListener(java.awt.event.MouseListener listener)

Add the argument MouseListener to the Canvas for this MCP instance.


removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener listener)

Remove the argument MouseListener from the Canvas for this MCP instance.


addKeyListener

public void addKeyListener(java.awt.event.KeyListener listener)

Add the argument KeyListener to the Canvas for this MCP instance.


removeKeyListener

public void removeKeyListener(java.awt.event.KeyListener listener)

Remove the argument KeyListener from the Canvas for this MCP instance.


getBrowserControl

public BrowserControl getBrowserControl()

Return the Webclient BrowserControl instance used by this MCP instance. This is useful for operations that require more complex browser control than that offered by MCP.


getRealizedVisibleBrowserWindow

public java.awt.Frame getRealizedVisibleBrowserWindow()

Return the realized and visible java.awt.Frame containing the actual browser window. There is no need to put this Frame inside of any surrounding Swing or AWT windows. It is sufficient to stand alone.


deleteBrowserControl

public void deleteBrowserControl()

Make invisible, and delete the BrowserControl instance for this MCP instance. Reset internal state of the instance so that a subsequent call to getRealizedVisibleBrowserWindow() will create a new Frame.


findElement

public org.w3c.dom.Element findElement(java.lang.String id)

Return the DOM Element with the given id or name. First, Document.getElementById() is called, passing the argument id. If an element is found, it is returned. Otherwise, the document is traversed and the first element encountered with a name equal to the argument id is returned. If no such element exists, null is returned.


findElementById

public org.w3c.dom.Element findElementById(java.lang.String id)

focusElement

public void focusElement(org.w3c.dom.Element toFocus)

appendKeyCodeToCurrentElementText

public void appendKeyCodeToCurrentElementText(int keyCode)

getAnchors

public java.util.List<org.w3c.dom.Element> getAnchors(java.lang.String id)

Given an argument id, return a List of DOM Element instances that are HTML anchors that are direct or indirect children of the element with that id.


getAnchors

public java.util.List<org.w3c.dom.Element> getAnchors()

Return a List of DOM Element instances that are HTML anchors that are present in the document. If no such elements exist, null is returned.


getChildElementsWithTagName

public java.util.List<org.w3c.dom.Element> getChildElementsWithTagName(org.w3c.dom.Element root,
                                                                       java.lang.String tagName)

Return a List of DOM Element instances whose tagName attribute is equal to the argument tagName. If no such elements exist, null is returned.


getChildElementsWithTagName

public java.util.List<org.w3c.dom.Element> getChildElementsWithTagName(java.lang.String id,
                                                                       java.lang.String tagName)

Return a List of DOM Element instances whose tagName attribute is equal to the argument tagName. If no such elements exist, null is returned.


findInPage

public boolean findInPage(java.lang.String toFind)

Return true if and only if the argument toFind occurs within the current page. Case is not significant. Users desiring more detailed find behavior should use getBrowserControl() to obtain a reference to the CurrentPage interface, which has more advanced methods pertaining to the current page.


clickElement

public void clickElement(org.w3c.dom.Element element)

Find the DOM element within the current page matching the argument id using findElement(java.lang.String). Use java.awt.Robot to click the element. Return immediately after clicking the element.


clickElement

public void clickElement(java.lang.String id)

Find the DOM element within the current page matching the argument id using findElement(java.lang.String). Use java.awt.Robot to click the element. Return immediately after clicking the element.


blockingClickElement

public void blockingClickElement(org.w3c.dom.Element element)

Find the DOM element within the current page matching the argument id using findElement(java.lang.String). Use java.awt.Robot to click the element. Block until the document load triggered by the click has completed.


blockingClickElement

public void blockingClickElement(java.lang.String idOrName)

Find the DOM element within the current page matching the argument id using findElement(java.lang.String). Use java.awt.Robot to click the element. Block until the document load triggered by the click has completed.


blockingLoad

public void blockingLoad(java.lang.String url)

Load the url, blocking until the load has completed.


waitUntilConditionMet

public boolean waitUntilConditionMet(Condition condition)

getTimeoutHandler

public TimeoutHandler getTimeoutHandler()

Return the currently installed TimeoutHandler, if any.


setTimeoutHandler

public void setTimeoutHandler(TimeoutHandler timeoutHandler)

Install an instance of TimeoutHandler that will be used for all subsequent browser interactions (clicks, loads, Ajax transactions, etc). To remove the TimeoutHandler, pass null to this method. If a handler is installed, the timer is automatically started when a browser interaction commences. If the browser interaction does not complete within getTimeout() milliseconds, the TimeoutHandler.timeout() method is called on the argument TimeoutHandler instance.


getTimeout

public long getTimeout()

Return the number of milliseconds that must elapse before the TimeoutHandler is called. Note that a TimeoutHandler is only called if the user has installed one by calling setTimeoutHandler(org.mozilla.mcp.TimeoutHandler).


setTimeout

public void setTimeout(long Timeout)

Set the number of milliseconds that must elapse before the TimeoutHandler is called, if such an instance has been installed via a previous call to @setTimeoutHandler.


getTimeoutWaitInterval

public long getTimeoutWaitInterval()

Return the number of milliseconds to wait between timeout checks.


setTimeoutWaitInterval

public void setTimeoutWaitInterval(long waitInterval)

Set the number of milliseconds to wait between timeout checks.



Copyright © 2002-2007 Mozilla.org All Rights Reserved.