org.apache.tapestry.test
Class AbstractIntegrationTestSuite

java.lang.Object
  extended by org.testng.Assert
      extended by org.apache.tapestry.test.AbstractIntegrationTestSuite
All Implemented Interfaces:
com.thoughtworks.selenium.Selenium

public class AbstractIntegrationTestSuite
extends org.testng.Assert
implements com.thoughtworks.selenium.Selenium

A base class for creating integration tests. Ths encapsulates starting up an in-process copy of Jetty, and in-process copy of SeleniumServer, and a Selenium client.

Unless you are very, very clever, you will want to run the tests sequentially. TestNG tends to run them in an arbitrary order unless you explicitly set the order. If you have managed to get TestNG to run tests in parallel, you may see further problems caused by a single client jumping all over your web application in an unpredictable order.

This class implements the Selenium interface, and delegates all those methods to the DefaultSelenium instance it creates. It also extends the normal exception reporting for any failed command or query to produce a more detailed report to the main console.

See Also:
JettyRunner

Field Summary
static String BASE_URL
           
static String DEFAULT_WEB_APP_ROOT
          Default directory containing the web application to be tested (this conforms to Maven's default folder).
static String DEFAULT_WEB_BROWSER_COMMAND
          Default browser in which to run tests - firefox
static int JETTY_PORT
          The port on which the internal copy of Jetty is executed.
static String PAGE_LOAD_TIMEOUT
          15 seconds
static String SUBMIT
           
 
Constructor Summary
  AbstractIntegrationTestSuite()
          Initializes the suite using DEFAULT_WEB_APP_ROOT.
protected AbstractIntegrationTestSuite(String webAppRoot)
           
protected AbstractIntegrationTestSuite(String webAppRoot, String browserCommand)
           
 
Method Summary
 void addLocationStrategy(String strategyName, String functionDefinition)
           
 void addSelection(String locator, String optionLocator)
           
 void allowNativeXpath(String allow)
           
 void altKeyDown()
           
 void altKeyUp()
           
 void answerOnNextPrompt(String answer)
           
protected  void assertAttribute(String locator, String expected)
          Used when the locator identifies an attribute, not an element.
protected  void assertAttributeSeries(String idFormat, int startIndex, String... values)
           
protected  void assertFieldValue(String locator, String expected)
           
protected  void assertFieldValueSeries(String idFormat, int startIndex, String... values)
           
protected  void assertSourcePresent(String... expected)
           
protected  void assertText(String locator, String expected)
          Asserts the text of an element, identified by the locator.
protected  void assertTextPresent(String... text)
           
protected  void assertTextSeries(String idFormat, int startIndex, String... values)
           
 void assignId(String locator, String identifier)
           
 void captureScreenshot(String filename)
           
 void check(String locator)
           
 void chooseCancelOnNextConfirmation()
           
 void chooseOkOnNextConfirmation()
           
 void cleanup()
           
 void click(String locator)
           
protected  void clickAndWait(String link)
           
 void clickAt(String locator, String coordString)
           
 void close()
           
 void controlKeyDown()
           
 void controlKeyUp()
           
 void createCookie(String nameValuePair, String optionsString)
           
 void deleteCookie(String name, String path)
           
 void doubleClick(String locator)
           
 void doubleClickAt(String locator, String coordString)
           
 void dragAndDrop(String locator, String movementsString)
           
 void dragAndDropToObject(String locatorOfObjectToBeDragged, String locatorOfDragDestinationObject)
           
 void dragdrop(String locator, String movementsString)
           
 void fireEvent(String locator, String eventName)
           
 String getAlert()
           
 String[] getAllButtons()
           
 String[] getAllFields()
           
 String[] getAllLinks()
           
 String[] getAllWindowIds()
           
 String[] getAllWindowNames()
           
 String[] getAllWindowTitles()
           
 String getAttribute(String attributeLocator)
           
 String[] getAttributeFromAllWindows(String attributeName)
           
 String getBodyText()
           
 String getConfirmation()
           
 String getCookie()
           
 Number getCursorPosition(String locator)
           
 Number getElementHeight(String locator)
           
 Number getElementIndex(String locator)
           
 Number getElementPositionLeft(String locator)
           
 Number getElementPositionTop(String locator)
           
 Number getElementWidth(String locator)
           
 String getEval(String script)
           
 String getExpression(String expression)
           
 String getHtmlSource()
           
 String getLocation()
           
 Number getMouseSpeed()
           
 String getPrompt()
           
 String getSelectedId(String selectLocator)
           
 String[] getSelectedIds(String selectLocator)
           
 String getSelectedIndex(String selectLocator)
           
 String[] getSelectedIndexes(String selectLocator)
           
 String getSelectedLabel(String selectLocator)
           
 String[] getSelectedLabels(String selectLocator)
           
 String getSelectedValue(String selectLocator)
           
 String[] getSelectedValues(String selectLocator)
           
 String[] getSelectOptions(String selectLocator)
           
 void getSpeed()
           
 String getTable(String tableCellAddress)
           
 String getText(String locator)
           
 String getTitle()
           
 String getValue(String locator)
           
 boolean getWhetherThisFrameMatchFrameExpression(String currentFrameString, String target)
           
 boolean getWhetherThisWindowMatchWindowExpression(String currentWindowString, String target)
           
 Number getXpathCount(String xpath)
           
 void goBack()
           
 void highlight(String locator)
           
 boolean isAlertPresent()
           
 boolean isChecked(String locator)
           
 boolean isConfirmationPresent()
           
 boolean isEditable(String locator)
           
 boolean isElementPresent(String locator)
           
 boolean isOrdered(String locator1, String locator2)
           
 boolean isPromptPresent()
           
 boolean isSomethingSelected(String selectLocator)
           
 boolean isTextPresent(String pattern)
           
 boolean isVisible(String locator)
           
 void keyDown(String locator, String keycode)
           
 void keyPress(String locator, String keycode)
           
 void keyUp(String locator, String keycode)
           
 void metaKeyDown()
           
 void metaKeyUp()
           
 void mouseDown(String locator)
           
 void mouseDownAt(String locator, String coordString)
           
 void mouseMove(String locator)
           
 void mouseMoveAt(String locator, String coordString)
           
 void mouseOut(String locator)
           
 void mouseOver(String locator)
           
 void mouseUp(String locator)
           
 void mouseUpAt(String locator, String coordString)
           
 void open(String url)
           
 void openWindow(String url, String windowID)
           
 void refresh()
           
 void removeAllSelections(String locator)
           
 void removeSelection(String locator, String optionLocator)
           
 void runScript(String script)
           
 void select(String selectLocator, String optionLocator)
           
 void selectFrame(String locator)
           
 void selectWindow(String windowID)
           
 void setBrowserLogLevel(String logLevel)
           
 void setContext(String context)
           
 void setCursorPosition(String locator, String position)
           
 void setMouseSpeed(String pixels)
           
 void setSpeed(String value)
           
 void setTimeout(String timeout)
           
 void setup()
           
 void shiftKeyDown()
           
 void shiftKeyUp()
           
 void start()
           
protected  void start(String... linkText)
          Used to start a typical test, by opening to the base URL and clicking through a series of links.
 void stop()
           
 void submit(String formLocator)
           
 void type(String locator, String value)
           
 void typeKeys(String locator, String value)
           
 void uncheck(String locator)
           
 void waitForCondition(String script, String timeout)
           
 void waitForFrameToLoad(String frameAddress, String timeout)
           
 void waitForPageToLoad()
          Waits the default time for the page to load.
 void waitForPageToLoad(String timeout)
           
 void waitForPopUp(String windowID, String timeout)
           
 void windowFocus()
           
 void windowMaximize()
           
 
Methods inherited from class org.testng.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsNoOrder, assertEqualsNoOrder, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_WEB_APP_ROOT

public static final String DEFAULT_WEB_APP_ROOT
Default directory containing the web application to be tested (this conforms to Maven's default folder).

See Also:
Constant Field Values

DEFAULT_WEB_BROWSER_COMMAND

public static final String DEFAULT_WEB_BROWSER_COMMAND
Default browser in which to run tests - firefox

See Also:
Constant Field Values

PAGE_LOAD_TIMEOUT

public static final String PAGE_LOAD_TIMEOUT
15 seconds

See Also:
Constant Field Values

JETTY_PORT

public static final int JETTY_PORT
The port on which the internal copy of Jetty is executed.

See Also:
Constant Field Values

BASE_URL

public static final String BASE_URL

SUBMIT

public static final String SUBMIT
See Also:
Constant Field Values
Constructor Detail

AbstractIntegrationTestSuite

public AbstractIntegrationTestSuite()
Initializes the suite using DEFAULT_WEB_APP_ROOT.


AbstractIntegrationTestSuite

protected AbstractIntegrationTestSuite(String webAppRoot)
Parameters:
webAppRoot - the directory containing the web application to be tested.

AbstractIntegrationTestSuite

protected AbstractIntegrationTestSuite(String webAppRoot,
                                       String browserCommand)
Parameters:
webAppRoot - web application root (default src/main/webapp)
browserCommand - browser command to pass to selenium. Default is *firefox, syntax for custom browsers is *custom <path_to_browser>, e.g. *custom /usr/lib/mozilla-firefox/firefox
Method Detail

assertSourcePresent

protected final void assertSourcePresent(String... expected)

assertAttribute

protected final void assertAttribute(String locator,
                                     String expected)
Used when the locator identifies an attribute, not an element.

Parameters:
locator - identifies the attribute whose value is to be asserted
expected - expected value for the attribute

assertText

protected final void assertText(String locator,
                                String expected)
Asserts the text of an element, identified by the locator.

Parameters:
locator - identifies the element whose text value is to be asserted
expected - expected value for the element's text

assertTextPresent

protected final void assertTextPresent(String... text)

assertFieldValue

protected final void assertFieldValue(String locator,
                                      String expected)

clickAndWait

protected final void clickAndWait(String link)

assertTextSeries

protected final void assertTextSeries(String idFormat,
                                      int startIndex,
                                      String... values)

assertAttributeSeries

protected final void assertAttributeSeries(String idFormat,
                                           int startIndex,
                                           String... values)

assertFieldValueSeries

protected final void assertFieldValueSeries(String idFormat,
                                            int startIndex,
                                            String... values)

cleanup

public void cleanup()
             throws Exception
Throws:
Exception

setup

public void setup()
           throws Exception
Throws:
Exception

addSelection

public void addSelection(String locator,
                         String optionLocator)
Specified by:
addSelection in interface com.thoughtworks.selenium.Selenium

answerOnNextPrompt

public void answerOnNextPrompt(String answer)
Specified by:
answerOnNextPrompt in interface com.thoughtworks.selenium.Selenium

check

public void check(String locator)
Specified by:
check in interface com.thoughtworks.selenium.Selenium

chooseCancelOnNextConfirmation

public void chooseCancelOnNextConfirmation()
Specified by:
chooseCancelOnNextConfirmation in interface com.thoughtworks.selenium.Selenium

chooseOkOnNextConfirmation

public void chooseOkOnNextConfirmation()
Specified by:
chooseOkOnNextConfirmation in interface com.thoughtworks.selenium.Selenium

click

public void click(String locator)
Specified by:
click in interface com.thoughtworks.selenium.Selenium

doubleClick

public void doubleClick(String locator)
Specified by:
doubleClick in interface com.thoughtworks.selenium.Selenium

clickAt

public void clickAt(String locator,
                    String coordString)
Specified by:
clickAt in interface com.thoughtworks.selenium.Selenium

doubleClickAt

public void doubleClickAt(String locator,
                          String coordString)
Specified by:
doubleClickAt in interface com.thoughtworks.selenium.Selenium

close

public void close()
Specified by:
close in interface com.thoughtworks.selenium.Selenium

fireEvent

public void fireEvent(String locator,
                      String eventName)
Specified by:
fireEvent in interface com.thoughtworks.selenium.Selenium

getAlert

public String getAlert()
Specified by:
getAlert in interface com.thoughtworks.selenium.Selenium

getAllButtons

public String[] getAllButtons()
Specified by:
getAllButtons in interface com.thoughtworks.selenium.Selenium

getAllFields

public String[] getAllFields()
Specified by:
getAllFields in interface com.thoughtworks.selenium.Selenium

getAttributeFromAllWindows

public String[] getAttributeFromAllWindows(String attributeName)
Specified by:
getAttributeFromAllWindows in interface com.thoughtworks.selenium.Selenium

dragdrop

public void dragdrop(String locator,
                     String movementsString)
Specified by:
dragdrop in interface com.thoughtworks.selenium.Selenium

setMouseSpeed

public void setMouseSpeed(String pixels)
Specified by:
setMouseSpeed in interface com.thoughtworks.selenium.Selenium

getMouseSpeed

public Number getMouseSpeed()
Specified by:
getMouseSpeed in interface com.thoughtworks.selenium.Selenium

dragAndDrop

public void dragAndDrop(String locator,
                        String movementsString)
Specified by:
dragAndDrop in interface com.thoughtworks.selenium.Selenium

dragAndDropToObject

public void dragAndDropToObject(String locatorOfObjectToBeDragged,
                                String locatorOfDragDestinationObject)
Specified by:
dragAndDropToObject in interface com.thoughtworks.selenium.Selenium

windowFocus

public void windowFocus()
Specified by:
windowFocus in interface com.thoughtworks.selenium.Selenium

windowMaximize

public void windowMaximize()
Specified by:
windowMaximize in interface com.thoughtworks.selenium.Selenium

getAllWindowIds

public String[] getAllWindowIds()
Specified by:
getAllWindowIds in interface com.thoughtworks.selenium.Selenium

getAllWindowNames

public String[] getAllWindowNames()
Specified by:
getAllWindowNames in interface com.thoughtworks.selenium.Selenium

getAllWindowTitles

public String[] getAllWindowTitles()
Specified by:
getAllWindowTitles in interface com.thoughtworks.selenium.Selenium

getAllLinks

public String[] getAllLinks()
Specified by:
getAllLinks in interface com.thoughtworks.selenium.Selenium

getAttribute

public String getAttribute(String attributeLocator)
Specified by:
getAttribute in interface com.thoughtworks.selenium.Selenium

getBodyText

public String getBodyText()
Specified by:
getBodyText in interface com.thoughtworks.selenium.Selenium

getConfirmation

public String getConfirmation()
Specified by:
getConfirmation in interface com.thoughtworks.selenium.Selenium

getCursorPosition

public Number getCursorPosition(String locator)
Specified by:
getCursorPosition in interface com.thoughtworks.selenium.Selenium

getEval

public String getEval(String script)
Specified by:
getEval in interface com.thoughtworks.selenium.Selenium

getExpression

public String getExpression(String expression)
Specified by:
getExpression in interface com.thoughtworks.selenium.Selenium

getXpathCount

public Number getXpathCount(String xpath)
Specified by:
getXpathCount in interface com.thoughtworks.selenium.Selenium

assignId

public void assignId(String locator,
                     String identifier)
Specified by:
assignId in interface com.thoughtworks.selenium.Selenium

allowNativeXpath

public void allowNativeXpath(String allow)
Specified by:
allowNativeXpath in interface com.thoughtworks.selenium.Selenium

getHtmlSource

public String getHtmlSource()
Specified by:
getHtmlSource in interface com.thoughtworks.selenium.Selenium

getLocation

public String getLocation()
Specified by:
getLocation in interface com.thoughtworks.selenium.Selenium

getPrompt

public String getPrompt()
Specified by:
getPrompt in interface com.thoughtworks.selenium.Selenium

getSelectedId

public String getSelectedId(String selectLocator)
Specified by:
getSelectedId in interface com.thoughtworks.selenium.Selenium

getSelectedIds

public String[] getSelectedIds(String selectLocator)
Specified by:
getSelectedIds in interface com.thoughtworks.selenium.Selenium

getSelectedIndex

public String getSelectedIndex(String selectLocator)
Specified by:
getSelectedIndex in interface com.thoughtworks.selenium.Selenium

getSelectedIndexes

public String[] getSelectedIndexes(String selectLocator)
Specified by:
getSelectedIndexes in interface com.thoughtworks.selenium.Selenium

getSelectedLabel

public String getSelectedLabel(String selectLocator)
Specified by:
getSelectedLabel in interface com.thoughtworks.selenium.Selenium

getSelectedLabels

public String[] getSelectedLabels(String selectLocator)
Specified by:
getSelectedLabels in interface com.thoughtworks.selenium.Selenium

getSelectedValue

public String getSelectedValue(String selectLocator)
Specified by:
getSelectedValue in interface com.thoughtworks.selenium.Selenium

getSelectedValues

public String[] getSelectedValues(String selectLocator)
Specified by:
getSelectedValues in interface com.thoughtworks.selenium.Selenium

getSelectOptions

public String[] getSelectOptions(String selectLocator)
Specified by:
getSelectOptions in interface com.thoughtworks.selenium.Selenium

getTable

public String getTable(String tableCellAddress)
Specified by:
getTable in interface com.thoughtworks.selenium.Selenium

getText

public String getText(String locator)
Specified by:
getText in interface com.thoughtworks.selenium.Selenium

highlight

public void highlight(String locator)
Specified by:
highlight in interface com.thoughtworks.selenium.Selenium

getTitle

public String getTitle()
Specified by:
getTitle in interface com.thoughtworks.selenium.Selenium

getValue

public