com.jniwrapper.win32.ie.scripting
Class Robot

java.lang.Object
  extended by com.jniwrapper.win32.ie.scripting.Robot

public class Robot
extends java.lang.Object

This class implements functionality that can be used in automatic testings. Implements useful function that can emulate users input from keyboard, mouse, dealays and several functions for searching elements in the document.


Constructor Summary
Robot(WebBrowser browser)
          Creates instance of ScriptingEngine class.
Robot(WebBrowser browser, boolean forceWaiting)
          Creates instance of ScriptingEngine class.
 
Method Summary
 void click()
          Simulates mouse click on the currently selected element.
 void click(org.w3c.dom.Element elemnt)
          Invokes click() method in the specified element.
 void click(java.lang.String elementID)
          Simulates mouse click on the specified element.
 org.w3c.dom.Element findButtonByText(java.lang.String text)
          Searches a button by spcified text.
 org.w3c.dom.Element findElement(java.lang.String elementID)
          Returns an element with a specified ID.
 org.w3c.dom.Element findElementByText(java.lang.String text)
          Searches an element by spcified text.
 org.w3c.dom.Element findInputByText(java.lang.String text)
          Searches an input by spcified text.
 org.w3c.dom.Element findLinkByText(java.lang.String text)
          Searches a link by spcified text.
 org.w3c.dom.Element findLinkByText(java.lang.String text, java.util.Comparator comparator)
          Searches a link by spcified text.
 void focusElement(java.lang.String elementID)
          Focuses an element with a specified ID.
 org.w3c.dom.html.HTMLElement getActiveElement()
          Returs current element.
 void inputFileName(java.lang.String elementID, java.lang.String value)
          This method is specially designed to populate a file input control.
 void inputString(java.lang.String value)
          Inputs a string into an active element.
 void navigate(java.lang.String url)
          Navigates browser to the specified url.
 void pressButton(java.lang.String elementID)
          Presses a button with specified ID.
 void selectListItem(java.lang.String elementID, int index)
          Selects a item by index in specified list.
 void selectListItem(java.lang.String elementID, java.lang.String text)
          Selects a item by item test in specified list.
 void sendKeys(java.lang.String value)
          Sends the specified string to the currently focused element, using the SendKeys method of the WScript.Shell COM object.
 void sleep(int milliseconds)
          Forces current thread to sleep.
 void submitPage()
          Submites the page by sending 'Enter' key to the current document.
 void typeKey(char key)
          Types a character to the active element.
 void typeString(java.lang.String value)
          Types a string into a currently selected element.
 void typeString(java.lang.String elementID, java.lang.String value)
          Focuses element by specified ID and types a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Robot

public Robot(WebBrowser browser)
Creates instance of ScriptingEngine class.

Parameters:
browser -

Robot

public Robot(WebBrowser browser,
             boolean forceWaiting)
Creates instance of ScriptingEngine class.

Method Detail

navigate

public void navigate(java.lang.String url)
Navigates browser to the specified url.

Parameters:
url - url to navigate

typeKey

public void typeKey(char key)
Types a character to the active element.

Parameters:
key - character to type

sendKeys

public void sendKeys(java.lang.String value)
Sends the specified string to the currently focused element, using the SendKeys method of the WScript.Shell COM object.

Parameters:
value - a value to set

inputFileName

public void inputFileName(java.lang.String elementID,
                          java.lang.String value)
This method is specially designed to populate a file input control.

Parameters:
elementID - id of a file input control
value - a file name to set

typeString

public void typeString(java.lang.String value)
Types a string into a currently selected element.


typeString

public void typeString(java.lang.String elementID,
                       java.lang.String value)
Focuses element by specified ID and types a string.


inputString

public void inputString(java.lang.String value)
Inputs a string into an active element.


pressButton

public void pressButton(java.lang.String elementID)
Presses a button with specified ID.


focusElement

public void focusElement(java.lang.String elementID)
Focuses an element with a specified ID.


selectListItem

public void selectListItem(java.lang.String elementID,
                           int index)
Selects a item by index in specified list.


selectListItem

public void selectListItem(java.lang.String elementID,
                           java.lang.String text)
Selects a item by item test in specified list.


click

public void click()
Simulates mouse click on the currently selected element.


click

public void click(java.lang.String elementID)
Simulates mouse click on the specified element.

Parameters:
elementID -

click

public void click(org.w3c.dom.Element elemnt)
Invokes click() method in the specified element.

Parameters:
elemnt - element to click

submitPage

public void submitPage()
Submites the page by sending 'Enter' key to the current document.


getActiveElement

public org.w3c.dom.html.HTMLElement getActiveElement()
Returs current element.

Returns:
current element

findElement

public org.w3c.dom.Element findElement(java.lang.String elementID)
Returns an element with a specified ID.


findLinkByText

public org.w3c.dom.Element findLinkByText(java.lang.String text)
Searches a link by spcified text.

Parameters:
text - text to find
Returns:
found element or null

findLinkByText

public org.w3c.dom.Element findLinkByText(java.lang.String text,
                                          java.util.Comparator comparator)
Searches a link by spcified text.

Parameters:
text - text to find
comparator - comparator which implements string comparation algorithm, such as "starts with", "ends with", "contains" etc.
Returns:
found element or null

findInputByText

public org.w3c.dom.Element findInputByText(java.lang.String text)
Searches an input by spcified text.

Parameters:
text - text to find
Returns:
found element or null

findButtonByText

public org.w3c.dom.Element findButtonByText(java.lang.String text)
Searches a button by spcified text.

Parameters:
text - text to find
Returns:
found element or null

findElementByText

public org.w3c.dom.Element findElementByText(java.lang.String text)
Searches an element by spcified text.

Parameters:
text - text to find
Returns:
found element or null

sleep

public void sleep(int milliseconds)
Forces current thread to sleep.

Parameters:
milliseconds -