com.atlassian.confluence
Class ThreadLocalWebTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.atlassian.confluence.ThreadLocalWebTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AbstractAtlassianWebTestCase

public abstract class ThreadLocalWebTestCase
extends junit.framework.TestCase

This is a copy of WebTestCase (version 1.4.1). This version differs from the original in that it stores its WebTester in a thread local instead of a local field. This provides thread safety over the tester if multiple threads share this test case (which is the case with TestNG).


Constructor Summary
ThreadLocalWebTestCase()
           
ThreadLocalWebTestCase(String name)
           
 
Method Summary
 void assertButtonNotPresent(String buttonId)
          Assert that a button with a given id is not present in the current window.
 void assertButtonNotPresentWithText(String text)
          Assert that a button with a given text is not present in the current window.
 void assertButtonPresent(String buttonId)
          Assert that a button with a given id is present in the current window.
A button can be the following HTML elements: button input button button
 void assertButtonPresentWithText(String text)
          Assert that a button with a given text is present in the current window.
 void assertCheckboxNotPresent(String checkboxName)
          Assert that a form checkbox with a given name is not present.
 void assertCheckboxNotPresent(String checkboxName, String checkboxValue)
          Assert that a given checkbox is not present.
 void assertCheckboxNotSelected(String checkBoxName)
          Assert that a specific checkbox is not selected.
 void assertCheckboxNotSelected(String checkBoxName, String checkBoxValue)
          Assert that a specific checkbox is not selected.
 void assertCheckboxPresent(String checkboxName)
          Assert that a form checkbox with a given name is present.
 void assertCheckboxPresent(String checkboxName, String checkboxValue)
          Assert that a given checkbox is present.
 void assertCheckboxSelected(String checkBoxName)
          Assert that a specific checkbox is selected.
 void assertCheckboxSelected(String checkBoxName, String checkBoxValue)
          Assert that a specific checkbox is selected.
 void assertCookiePresent(String cookieName)
          Checks to see if a cookie is present in the response.
 void assertCookieValueEquals(String cookieName, String expectedValue)
          Check to see if a cookie has the given value.
 void assertCookieValueMatch(String cookieName, String regexp)
          Check to see if a cookie value match the given regexp.
 void assertDownloadedFileEquals(URL expected)
          Download the current page (or file) and compare it with the given file.
 void assertElementNotPresent(String anID)
          Assert that an element with a given id is not present.
 void assertElementNotPresentByXPath(String xpath)
          Assert that an element with a given xpath is not present.
 void assertElementPresent(String anID)
          Assert that an element with a given id is present.
 void assertElementPresentByXPath(String xpath)
          Assert that an element with a given xpath is present.
 void assertFormElementEmpty(String formElementName)
          Deprecated.  
 void assertFormElementEquals(String formElementName, String expectedValue)
          Deprecated.  
 void assertFormElementMatch(String formElementName, String regexp)
          Deprecated.  
 void assertFormElementNotPresent(String formElementName)
          Assert that a form input element with a given name is not present.
 void assertFormElementPresent(String formElementName)
          Assert that a form input element with a given name is present.
 void assertFormNotPresent()
          Assert that there is not a form present.
 void assertFormNotPresent(String nameOrID)
          Assert that there is not a form with the specified name or id present.
 void assertFormPresent()
          Assert that there is a form present.
 void assertFormPresent(String nameOrID)
          Assert that there is a form with the specified name or id present.
 void assertFramePresent(String frameNameOrId)
          Assert that a frame with the given name or ID is present.
 void assertHiddenFieldPresent(String formElementName, String expectedValue)
          Assert that an input hidden element with name formElementName has the expectedValue value.
 void assertImagePresent(String imageSrc, String imageAlt)
           
 void assertImageValid(String imageSrc, String imageAlt)
           
 void assertImageValidAndStore(String imageSrc, String imageAlt, File out)
          Asserts that the image with the given src and alt attribute values exist in the page and is an actual reachable image, then saves it as png with the given file name.
 void assertKeyInTable(String tableSummaryOrId, String key)
          Assert that the value of a given web resource is present in a specific table.
 void assertKeyInTable(String tableSummaryOrId, String key, Object[] args)
          Assert that the value of a given web resource is present in a specific table.
 void assertKeyNotInTable(String tableSummaryOrId, String key)
          Assert that the value of a given web resource is not present in a specific table.
 void assertKeyNotPresent(String key)
          Assert that a web resource's value is not present.
 void assertKeyNotPresent(String key, Object[] args)
          Assert that a web resource's formatted value is not present.
 void assertKeyPresent(String key)
          Assert that a web resource's value is present.
 void assertKeyPresent(String key, Object[] args)
          Assert that a web resource's value (with formatting) is present
 void assertKeysInTable(String tableSummaryOrId, String[] keys)
          Assert that the values of a set of web resources are all present in a specific table.
 void assertKeysInTable(String tableSummaryOrId, String[] keys, Object[][] args)
          Assert that the values of a set of web resources are all present in a specific table.
 void assertLinkNotPresent(String linkId)
          Assert that no link with the given id is present in the response.
 void assertLinkNotPresentWithExactText(String linkText)
          Assert that no link containing the Exact text is present.
 void assertLinkNotPresentWithExactText(String linkText, int index)
          Assert that no link containing the Exact text is present.
 void assertLinkNotPresentWithImage(String imageFileName)
          Assert that a link containing a specified image is not present.
 void assertLinkNotPresentWithText(String linkText)
          Assert that no link containing the supplied text is present.
 void assertLinkNotPresentWithText(String linkText, int index)
          Assert that no link containing the supplied text is present.
 void assertLinkPresent(String linkId)
          Assert that a link with a given id is present in the response.
 void assertLinkPresentWithExactText(String linkText)
          Assert that a link containing the Exact text is present.
 void assertLinkPresentWithExactText(String linkText, int index)
          Assert that a link containing the Exact text is present.
 void assertLinkPresentWithImage(String imageFileName)
          Assert that a link containing a specified image is present.
 void assertLinkPresentWithText(String linkText)
          Assert that a link containing the supplied text is present.
 void assertLinkPresentWithText(String linkText, int index)
          Assert that a link containing the supplied text is present.
 void assertMatch(String regexp)
          Assert that supplied regexp is matched.
 void assertMatchInElement(String elementID, String regexp)
          Assert that a given element matches a specific regexp.
 void assertMatchInTable(String tableSummaryNameOrId, String regexp)
          Assert that supplied regexp is matched in a specific table.
 void assertMatchInTable(String tableSummaryOrId, String[] regexp)
          Assert that a set of regexp values are all matched in a specific table.
 void assertNoMatch(String regexp)
          Assert that supplied regexp is not present.
 void assertNoMatchInElement(String elementID, String regexp)
          Assert that a given element does not match a specific regexp.
 void assertNoMatchInTable(String tableSummaryNameOrId, String regexp)
          Assert that supplied regexp is not present in a specific table.
 void assertNoMatchInTable(String tableSummaryNameOrId, String[] regexp)
          Assert that none of a set of regexp values are present in a specific table.
 void assertRadioOptionNotPresent(String name, String radioOption)
          Assert that a specific option is not present in a radio group.
 void assertRadioOptionNotSelected(String name, String radioOption)
          Assert that a specific option is not selected in a radio group.
 void assertRadioOptionPresent(String name, String radioOption)
          Assert that a specific option is present in a radio group.
 void assertRadioOptionSelected(String name, String radioOption)
          Assert that a specific option is selected in a radio group.
 void assertResetButtonNotPresent()
          Assert that no reset button is present in the current form.
A reset button can be the following HTML elements: reset input reset button
 void assertResetButtonNotPresent(String buttonName)
          Assert that a reset button with a given name is not present.
A reset button can be the following HTML elements: reset input reset button
 void assertResetButtonPresent()
          Assert that a reset button is present.
 void assertResetButtonPresent(String buttonName)
          Assert that a reset button with a given name is present.
A reset button can be the following HTML elements: reset input reset button
 void assertSelectedOptionEquals(String selectName, String option)
           
 void assertSelectedOptionMatches(String selectName, String regexp)
           
 void assertSelectedOptionsEqual(String selectName, String[] labels)
          Assert that the currently selected display label(s) of a select box matches given label(s).
 void assertSelectedOptionsMatch(String selectName, String[] regexps)
          Assert that the currently selected display value(s) of a select box matches a given value(s).
 void assertSelectedOptionValueEquals(String selectName, String value)
          Assert that the currently selected value of a select box matches given value.
 void assertSelectedOptionValuesEqual(String selectName, String[] values)
          Assert that the currently selected value(s) of a select box matches given value(s).
 void assertSelectOptionNotPresent(String selectName, String optionLabel)
          Assert that a specific option is not present in a select box.
 void assertSelectOptionPresent(String selectName, String optionLabel)
          Assert that a specific option is present in a select box (by label).
 void assertSelectOptionsEqual(String selectName, String[] expectedOptions)
          Assert that the display values of a select element's options match a given array of strings.
 void assertSelectOptionsNotEqual(String selectName, String[] expectedOptions)
          Assert that the display values of a select element's options do not match a given array of strings.
 void assertSelectOptionsPresent(String selectName, String[] optionLabels)
          Assert that given options are present in a select box (by label).
 void assertSelectOptionValueNotPresent(String selectName, String optionValue)
           
 void assertSelectOptionValuePresent(String selectName, String optionValue)
          Assert that a specific option is present in a select box (by value).
 void assertSelectOptionValuesEqual(String selectName, String[] expectedValues)
          Assert that the values of a select element's options match a given array of strings.
 void assertSelectOptionValuesNotEqual(String selectName, String[] optionValues)
          Assert that the values of a select element's options do not match a given array of strings.
 void assertSelectOptionValuesPresent(String selectName, String[] optionValues)
          Assert that given options are present in a select box (by value).
 void assertSubmitButtonNotPresent()
          Assert that no submit button is present in the current form.
 void assertSubmitButtonNotPresent(String buttonName)
          Assert that a submit button with a given name is not present.
 void assertSubmitButtonPresent()
          Assert that a submit button is present.
 void assertSubmitButtonPresent(String buttonName)
          Assert that a submit button with a given name is present.
 void assertSubmitButtonPresent(String buttonName, String buttonValue)
          Assert that a submit button with a given name and value is present.
 void assertTableEquals(String tableSummaryNameOrId, String[][] expectedCellValues)
          Assert that a specific table matches a matrix of supplied text values.
 void assertTableEquals(String tableSummaryNameOrId, net.sourceforge.jwebunit.html.Table expectedTable)
          Assert that a specific table matches an ExpectedTable.
 void assertTableMatch(String tableSummaryOrId, String[][] expectedCellValues)
          Assert that a specific table matches a matrix of supplied regexps.
 void assertTableMatch(String tableSummaryOrId, net.sourceforge.jwebunit.html.Table expectedTable)
          Assert that a specific table matches an ExpectedTable.
 void assertTableNotPresent(String tableSummaryNameOrId)
          Assert that a table with a given summary or id value is not present.
 void assertTablePresent(String tableSummaryNameOrId)
          Assert that a table with a given summary or id value is present.
 void assertTableRowCountEquals(String tableSummaryNameOrId, int expectedRowCount)
          Assert that the number of rows for a specific table equals expected value.
 void assertTableRowsEqual(String tableSummaryNameOrId, int startRow, String[][] expectedTable)
          Assert that a range of rows for a specific table matches a matrix of supplied text values.
 void assertTableRowsEqual(String tableSummaryNameOrId, int startRow, net.sourceforge.jwebunit.html.Table expectedTable)
          Assert that a range of rows for a specific table matches a matrix of supplied text values.
 void assertTableRowsMatch(String tableSummaryOrId, int startRow, String[][] expectedTable)
          Assert that a range of rows for a specific table matches a matrix of supplied regexps.
 void assertTableRowsMatch(String tableSummaryOrId, int startRow, net.sourceforge.jwebunit.html.Table expectedTable)
          Assert that a range of rows for a specific table matches a matrix of supplied regexps.
 void assertTextFieldEquals(String formElementName, String expectedValue)
          Assert that an input text element with name formElementName has the expectedValue value.
 void assertTextInElement(String elementID, String text)
          Assert that a given element contains specific text.
 void assertTextInTable(String tableSummaryNameOrId, String text)
          Assert that supplied text is present in a specific table.
 void assertTextInTable(String tableSummaryOrId, String[] text)
          Assert that a set of text values are all present in a specific table.
 void assertTextNotInElement(String elementID, String text)
           
 void assertTextNotInTable(String tableSummaryNameOrId, String text)
          Assert that supplied text is not present in a specific table.
 void assertTextNotInTable(String tableSummaryNameOrId, String[] text)
          Assert that none of a set of text values are present in a specific table.
 void assertTextNotPresent(String text)
          Assert that supplied text is not present.
 void assertTextPresent(String text)
          Assert that supplied text is present.
 void assertTitleEquals(String title)
          Assert title of current html page in conversation matches an expected value.
 void assertTitleEqualsKey(String titleKey)
          Assert title of current html page matches the value of a specified web resource.
 void assertTitleEqualsKey(String titleKey, Object[] args)
          Assert title of current page matches formatted message resource
 void assertTitleMatch(String regexp)
          Assert title of current html page in conversation matches an expected regexp.
 void assertWindowCountEquals(int windowCount)
          Assert that the number of opened windows equals given value.
 void assertWindowPresent(int windowID)
          Assert that a window with the given ID is open.
 void assertWindowPresent(String windowName)
          Assert that a window with the given name is open.
 void assertWindowPresentWithTitle(String title)
          Assert that at least one window with the given title is open.
 void beginAt(String aRelativeURL)
          Begin conversation at a URL absolute or relative to base URL.
 void checkCheckbox(String checkBoxName)
          Select a specified checkbox.
 void checkCheckbox(String checkBoxName, String value)
          Select a specified checkbox.
 void clickButton(String buttonId)
          Click the button with the given id.
 void clickButtonWithText(String buttonValueText)
          Clicks a button with text of the value attribute.
 void clickElementByXPath(String xpath)
          Click element with given xpath.
 void clickLink(String linkId)
          Navigate by selection of a link with given id.
 void clickLinkWithExactText(String linkText)
          Navigate by selection of a link with the exact given text.
 void clickLinkWithExactText(String linkText, int index)
          Navigate by selecting Nth link with the exact given text.
 void clickLinkWithImage(String imageFileName)
          Navigate by selection of a link with a given image.
 void clickLinkWithText(String linkText)
          Navigate by selection of a link containing given text.
 void clickLinkWithText(String linkText, int index)
          Navigate by selecting Nth link containing given text.
 void clickRadioOption(String radioGroup, String radioOption)
          Clicks a radio option.
 void closeBrowser()
          Close the current conversation.
 void closeWindow()
          Close the current window.
 void dumpCookies()
          Print all the cookies to stdout.
 void dumpHtml()
          Deprecated. Use WebTester.getPageSource()
 void dumpHtml(PrintStream stream)
          Deprecated. Use WebTester.getPageSource()
 void dumpTable(String tableNameOrId)
          Dump the table as the 2D array that is used for assertions - for debugging purposes.
 void dumpTable(String tableNameOrId, PrintStream stream)
          Dump the table as the 2D array that is used for assertions - for debugging purposes.
 net.sourceforge.jwebunit.api.IJWebUnitDialog getDialog()
          Deprecated. You should not use plugin specific functionality. Please ask for a new core feature instead.
 String getElementAttributByXPath(String xpath, String attribute)
          Get the attribute value of the gicen element.
 String getElementTextByXPath(String xpath)
          Get text of the given element.
 String getFormElementValue(String formElementName)
          Deprecated.  
 Image getImage(String imageSrc, String imageAlt)
           
 String getMessage(String key)
          Return the value of a web resource based on its key.
 String getMessage(String key, Object[] args)
          Return the value of a web resource based on its key, using MessageFormat to perform parametric substitution with formatting.
 String getPageSource()
          Get the source of the HTML page (like in a real browser), or HTTP body for a non HTML content.
 String getServeurResponse()
          Get the last data sent by the server.
 net.sourceforge.jwebunit.html.Table getTable(String tableSummaryNameOrId)
           
 net.sourceforge.jwebunit.util.TestContext getTestContext()
          Provide access to test testContext.
 net.sourceforge.jwebunit.junit.WebTester getTester()
          Get internal WebTester.
 String getTestingEngineKey()
          Gets the Testing Engine Key that is used to find the proper testing engine class (HtmlUnitDialog / SeleniumDialog) for the tests.
 void gotoFrame(String frameNameOrId)
          Make the given frame active.
 void gotoPage(String url)
          Go to the given page like if user has typed the URL manually in the browser.
 void gotoPage(UrlBuilder urlBuilder)
          Go to the given page like if user has typed the URL manually in the browser.
 void gotoRootWindow()
          Make the root window active.
 void gotoWindow(int windowID)
          Make a given window active.
 void gotoWindow(String windowName)
          Make a given window active.
 void gotoWindowByTitle(String title)
          Make first window with the given title active.
protected  void removeThreadLocal()
           
 void reset()
          Reset the current form using the default reset button.
 void runBare()
          Clean up unused memory.
 void saveAs(File f)
          Save the last downloaded page (or file) to the disk.
 void selectOption(String selectName, String label)
          Select an option with a given display label in a select element.
 void selectOptionByValue(String selectName, String value)
          Select an option with a given value in a select element.
 void selectOptions(String selectName, String[] labels)
          Select options with given display labels in a select element.
 void selectOptionsByValues(String selectName, String[] values)
          Select options with given values in a select element.
 void setDialog(net.sourceforge.jwebunit.api.IJWebUnitDialog aIJWebUnitDialog)
          Set the testing engine.
 void setExpectedJavaScriptAlert(String message)
          Tell that the given alert box is expected.
 void setExpectedJavaScriptAlert(String[] messages)
          Tell that the given alert boxes are expected in the given order.
 void setExpectedJavaScriptConfirm(String[] messages, boolean[] actions)
          Tell that the given confirm boxes are expected in the given order.
 void setExpectedJavaScriptConfirm(String message, boolean action)
          Tell that the given confirm box is expected.
 void setExpectedJavaScriptPrompt(String[] messages, String[] inputs)
          Tell that the given prompt boxes are expected in the given order.
 void setExpectedJavaScriptPrompt(String message, String input)
          Tell that the given prompt box is expected.
 void setFormElement(String formElementName, String value)
          Deprecated. use setTextField or other methods
 void setScriptingEnabled(boolean value)
          Enable or disable Javascript support
 void setTestContext(net.sourceforge.jwebunit.util.TestContext aTestContext)
          Allows setting an external test testContext class that might be extended from TestContext.
 void setTester(net.sourceforge.jwebunit.junit.WebTester tester)
           
 void setTestingEngineKey(String testingEngineKey)
          Set the Testing Engine that you want to use for the tests based on the Testing Engine Key.
 void setTextField(String inputName, String value)
          Set the value of a text or password input field.
 void setWorkingForm(int index)
          Begin interaction with a specified form.
 void setWorkingForm(String nameOrId)
          Begin interaction with a specified form.
 void setWorkingForm(String nameOrId, int index)
          Begin interaction with a specified form.
 void submit()
          Submit form - default submit button will be used (unnamed submit button, or named button if there is only one on the form.
 void submit(String buttonName)
          Submit form by pressing named button.
 void submit(String buttonName, String buttonValue)
          Submit the form by pressing the named button with the given value (label).
protected  void tearDown()
           
 void uncheckCheckbox(String checkBoxName)
          Deselect a specified checkbox.
 void uncheckCheckbox(String checkBoxName, String value)
          Deselect a specified checkbox.
 void wrapWithPageSourceOnError(Runnable runnable)
          For use on those few occasions when the exception might be recoverable, but we still want to see what went wrong.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, setUp, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadLocalWebTestCase

public ThreadLocalWebTestCase(String name)

ThreadLocalWebTestCase

public ThreadLocalWebTestCase()
Method Detail

setTester

public void setTester(net.sourceforge.jwebunit.junit.WebTester tester)

tearDown

protected void tearDown()
                 throws Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

removeThreadLocal

protected void removeThreadLocal()

getTester

public net.sourceforge.jwebunit.junit.WebTester getTester()
Get internal WebTester.


runBare

public void runBare()
             throws Throwable
Clean up unused memory. Using setUp and tearDown is not an option for this requires the subclasses of this class to call the respective super methods. Also wrap any exceptions and include the URL and HTML for the current page.

Overrides:
runBare in class junit.framework.TestCase
Throws:
Throwable

getDialog

@Deprecated
public net.sourceforge.jwebunit.api.IJWebUnitDialog getDialog()
Deprecated. You should not use plugin specific functionality. Please ask for a new core feature instead.

Provides access to the testing engine for subclasses - in case functionality not yet wrapped is required by a test.

If the dialog is not explicitly set the jWebUnit framework will default to using the original testing engine, which is, htmlunit.

Returns:
IJWebUnitDialog instance used to wrapper htmlunit conversation.

closeBrowser

public void closeBrowser()
Close the current conversation.


closeWindow

public void closeWindow()
Close the current window.


setDialog

public void setDialog(net.sourceforge.jwebunit.api.IJWebUnitDialog aIJWebUnitDialog)
Set the testing engine.

Parameters:
aIJWebUnitDialog - Testing engine.

getTestContext

public net.sourceforge.jwebunit.util.TestContext getTestContext()
Provide access to test testContext.

Returns:
TestContext

setTestContext

public void setTestContext(net.sourceforge.jwebunit.util.TestContext aTestContext)
Allows setting an external test testContext class that might be extended from TestContext. Example: setTestContext(new CompanyATestContext());

CompanyATestContext extends TestContext.

Parameters:
aTestContext -

beginAt

public void beginAt(String aRelativeURL)
             throws net.sourceforge.jwebunit.exception.TestingEngineResponseException
Begin conversation at a URL absolute or relative to base URL. Use getTestContext().setBaseUrl(String) to define base URL. Absolute URL should start with "http://", "https://" or "www.".

Parameters:
aRelativeURL - absolute or relative URL (relative to base URL).
Throws:
net.sourceforge.jwebunit.exception.TestingEngineResponseException - If something bad happened (404)

getMessage

public String getMessage(String key)
Return the value of a web resource based on its key. This translates to a property file lookup with the locale based on the current TestContext.

Parameters:
key - name of the web resource.
Returns:
value of the web resource, encoded according to TestContext.

getMessage

public String getMessage(String key,
                         Object[] args)
Return the value of a web resource based on its key, using MessageFormat to perform parametric substitution with formatting.

Parameters:
key - name of the web resource.
args - array of arguments to be formatted into message
Returns:
value of the web resource after formatting
See Also:
MessageFormat

assertTitleEquals

public void assertTitleEquals(String title)
Assert title of current html page in conversation matches an expected value.

Parameters:
title - expected title value

assertTitleMatch

public void assertTitleMatch(String regexp)
Assert title of current html page in conversation matches an expected regexp.

Parameters:
regexp - expected title regexp

assertTitleEqualsKey

public void assertTitleEqualsKey(String titleKey)
Assert title of current html page matches the value of a specified web resource.

Parameters:
titleKey - web resource key for title

assertTitleEqualsKey

public void assertTitleEqualsKey(String titleKey,
                                 Object[] args)
Assert title of current page matches formatted message resource

Parameters:
titleKey -
args -

assertKeyPresent

public void assertKeyPresent(String key)
Assert that a web resource's value is present.

Parameters:
key - web resource name

assertKeyPresent

public void assertKeyPresent(String key,
                             Object[] args)
Assert that a web resource's value (with formatting) is present

Parameters:
key -
args -

assertTextPresent

public void assertTextPresent(String text)
Assert that supplied text is present.

Parameters:
text -

assertMatch

public void assertMatch(String regexp)
Assert that supplied regexp is matched.

Parameters:
regexp -

assertKeyNotPresent

public void assertKeyNotPresent(String key)
Assert that a web resource's value is not present.

Parameters:
key - web resource name

assertKeyNotPresent

public void assertKeyNotPresent(String key,
                                Object[] args)
Assert that a web resource's formatted value is not present.

Parameters:
key - web resource name

assertTextNotPresent

public void assertTextNotPresent(String text)
Assert that supplied text is not present.

Parameters:
text -

assertNoMatch

public void assertNoMatch(String regexp)
Assert that supplied regexp is not present.

Parameters:
regexp -

getTable

public net.sourceforge.jwebunit.html.Table getTable(String tableSummaryNameOrId)
Parameters:
tableSummaryNameOrId -
Returns:
Object that represent a html table in a way independent from plugin.

assertTablePresent

public void assertTablePresent(String tableSummaryNameOrId)
Assert that a table with a given summary or id value is present.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table

assertTableNotPresent

public void assertTableNotPresent(String tableSummaryNameOrId)
Assert that a table with a given summary or id value is not present.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table

assertKeyInTable

public void assertKeyInTable(String tableSummaryOrId,
                             String key)
Assert that the value of a given web resource is present in a specific table.

Parameters:
tableSummaryOrId - summary or id attribute value of table
key - web resource name

assertKeyInTable

public void assertKeyInTable(String tableSummaryOrId,
                             String key,
                             Object[] args)
Assert that the value of a given web resource is present in a specific table.

Parameters:
tableSummaryOrId - summary or id attribute value of table
key - web resource name

assertTextInTable

public void assertTextInTable(String tableSummaryNameOrId,
                              String text)
Assert that supplied text is present in a specific table.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
text -

assertMatchInTable

public void assertMatchInTable(String tableSummaryNameOrId,
                               String regexp)
Assert that supplied regexp is matched in a specific table.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
regexp -

assertKeysInTable

public void assertKeysInTable(String tableSummaryOrId,
                              String[] keys)
Assert that the values of a set of web resources are all present in a specific table.

Parameters:
tableSummaryOrId - summary, name or id attribute value of table
keys - Array of web resource names.

assertKeysInTable

public void assertKeysInTable(String tableSummaryOrId,
                              String[] keys,
                              Object[][] args)
Assert that the values of a set of web resources are all present in a specific table.

Parameters:
tableSummaryOrId - summary or id attribute value of table
keys - Array of web resource names.

assertTextInTable

public void assertTextInTable(String tableSummaryOrId,
                              String[] text)
Assert that a set of text values are all present in a specific table.

Parameters:
tableSummaryOrId - summary, name or id attribute value of table
text - Array of expected text values.

assertMatchInTable

public void assertMatchInTable(String tableSummaryOrId,
                               String[] regexp)
Assert that a set of regexp values are all matched in a specific table.

Parameters:
tableSummaryOrId - summary, name or id attribute value of table
regexp - Array of expected regexps to match.

assertKeyNotInTable

public void assertKeyNotInTable(String tableSummaryOrId,
                                String key)
Assert that the value of a given web resource is not present in a specific table.

Parameters:
tableSummaryOrId - summary, name or id attribute value of table
key - web resource name

assertTextNotInTable

public void assertTextNotInTable(String tableSummaryNameOrId,
                                 String text)
Assert that supplied text is not present in a specific table.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
text -

assertTextNotInTable

public void assertTextNotInTable(String tableSummaryNameOrId,
                                 String[] text)
Assert that none of a set of text values are present in a specific table.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
text - Array of text values

assertNoMatchInTable

public void assertNoMatchInTable(String tableSummaryNameOrId,
                                 String regexp)
Assert that supplied regexp is not present in a specific table.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
regexp - regular expression string expected not to match data in any table cell

assertNoMatchInTable

public void assertNoMatchInTable(String tableSummaryNameOrId,
                                 String[] regexp)
Assert that none of a set of regexp values are present in a specific table.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
regexp - Array of text values

assertTableEquals

public void assertTableEquals(String tableSummaryNameOrId,
                              net.sourceforge.jwebunit.html.Table expectedTable)
Assert that a specific table matches an ExpectedTable.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
expectedTable - represents expected values (colspan supported).

assertTableEquals

public void assertTableEquals(String tableSummaryNameOrId,
                              String[][] expectedCellValues)
Assert that a specific table matches a matrix of supplied text values.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
expectedCellValues - double dimensional array of expected values

assertTableRowsEqual

public void assertTableRowsEqual(String tableSummaryNameOrId,
                                 int startRow,
                                 net.sourceforge.jwebunit.html.Table expectedTable)
Assert that a range of rows for a specific table matches a matrix of supplied text values.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
startRow - index of start row for comparison
expectedTable - represents expected values (colspan and rowspan supported).

assertTableRowsEqual

public void assertTableRowsEqual(String tableSummaryNameOrId,
                                 int startRow,
                                 String[][] expectedTable)
Assert that a range of rows for a specific table matches a matrix of supplied text values.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
startRow - index of start row for comparison
expectedTable - represents expected values (colspan and rowspan supported).

assertTableRowCountEquals

public void assertTableRowCountEquals(String tableSummaryNameOrId,
                                      int expectedRowCount)
Assert that the number of rows for a specific table equals expected value.

Parameters:
tableSummaryNameOrId - summary, name or id attribute value of table
expectedRowCount - expected row count.

assertTableMatch

public void assertTableMatch(String tableSummaryOrId,
                             net.sourceforge.jwebunit.html.Table expectedTable)
Assert that a specific table matches an ExpectedTable.

Parameters:
tableSummaryOrId - summary or id attribute value of table
expectedTable - represents expected regexps (colspan supported).

assertTableMatch

public void assertTableMatch(String tableSummaryOrId,
                             String[][] expectedCellValues)
Assert that a specific table matches a matrix of supplied regexps.

Parameters:
tableSummaryOrId - summary or id attribute value of table
expectedCellValues - double dimensional array of expected regexps

assertTableRowsMatch

public void assertTableRowsMatch(String tableSummaryOrId,
                                 int startRow,
                                 net.sourceforge.jwebunit.html.Table expectedTable)
Assert that a range of rows for a specific table matches a matrix of supplied regexps.

Parameters:
tableSummaryOrId - summary or id attribute value of table
startRow - index of start row for comparison
expectedTable - represents expected regexps (colspan and rowspan supported).

assertTableRowsMatch

public void assertTableRowsMatch(String tableSummaryOrId,
                                 int startRow,
                                 String[][] expectedTable)
Assert that a range of rows for a specific table matches a matrix of supplied regexps.

Parameters:
tableSummaryOrId - summary or id attribute value of table
startRow - index of start row for comparison
expectedTable - represents expected regexps (colspan and rowspan not supported).

assertFormElementPresent

public void assertFormElementPresent(String formElementName)
Assert that a form input element with a given name is present.

Parameters:
formElementName -

assertFormElementNotPresent

public void assertFormElementNotPresent(String formElementName)
Assert that a form input element with a given name is not present.

Parameters:
formElementName -

assertCheckboxPresent

public void assertCheckboxPresent(String checkboxName)
Assert that a form checkbox with a given name is present.

Parameters:
checkboxName - checkbox name.

assertCheckboxPresent

public void assertCheckboxPresent(String checkboxName,
                                  String checkboxValue)
Assert that a given checkbox is present.

Parameters:
checkboxName - checkbox name attribute.
checkboxValue - checkbox value attribute.

assertCheckboxNotPresent

public void assertCheckboxNotPresent(String checkboxName)
Assert that a form checkbox with a given name is not present.

Parameters:
checkboxName - checkbox name.

assertCheckboxNotPresent

public void assertCheckboxNotPresent(String checkboxName,
                                     String checkboxValue)
Assert that a given checkbox is not present.

Parameters:
checkboxName - checkbox name.
checkboxValue - checkbox value attribute.

assertFormPresent

public void assertFormPresent()
Assert that there is a form present.


assertFormPresent

public void assertFormPresent(String nameOrID)
Assert that there is a form with the specified name or id present.

Parameters:
nameOrID -

assertFormNotPresent

public void assertFormNotPresent()
Assert that there is not a form present.


assertFormNotPresent

public void assertFormNotPresent(String nameOrID)
Assert that there is not a form with the specified name or id present.

Parameters:
nameOrID -

assertFormElementEquals

@Deprecated
public void assertFormElementEquals(String formElementName,
                                               String expectedValue)
Deprecated. 

Assert that a specific form element has an expected value. Can be used to check hidden input.

Parameters:
formElementName -
expectedValue -

assertFormElementMatch

@Deprecated
public void assertFormElementMatch(String formElementName,
                                              String regexp)
Deprecated. 

Assert that a specific form element matches an expected regexp.

Parameters:
formElementName -
regexp -

assertFormElementEmpty

@Deprecated
public void assertFormElementEmpty(String formElementName)
Deprecated. 

Assert that a form element had no value / is empty.

Parameters:
formElementName -

assertTextFieldEquals

public void assertTextFieldEquals(String formElementName,
                                  String expectedValue)
Assert that an input text element with name formElementName has the expectedValue value.

Parameters:
formElementName - the value of the name attribute of the element
expectedValue - the expected value of the given input element

assertHiddenFieldPresent

public void assertHiddenFieldPresent(String formElementName,
                                     String expectedValue)
Assert that an input hidden element with name formElementName has the expectedValue value.

Parameters:
formElementName - the value of the name attribute of the element
expectedValue - the expected value of the given input element

assertCheckboxSelected

public void assertCheckboxSelected(String checkBoxName)
Assert that a specific checkbox is selected.

Parameters:
checkBoxName -

assertCheckboxSelected

public void assertCheckboxSelected(String checkBoxName,
                                   String checkBoxValue)
Assert that a specific checkbox is selected.

Parameters:
checkBoxName -
checkBoxValue -

assertCheckboxNotSelected

public void assertCheckboxNotSelected(String checkBoxName)
Assert that a specific checkbox is not selected.

Parameters:
checkBoxName -

assertCheckboxNotSelected

public void assertCheckboxNotSelected(String checkBoxName,
                                      String checkBoxValue)
Assert that a specific checkbox is not selected.

Parameters:
checkBoxName -
checkBoxValue -

assertRadioOptionPresent

public void assertRadioOptionPresent(String name,
                                     String radioOption)
Assert that a specific option is present in a radio group.

Parameters:
name - radio group name.
radioOption - option to test for.

assertRadioOptionNotPresent

public void assertRadioOptionNotPresent(String name,
                                        String radioOption)
Assert that a specific option is not present in a radio group.

Parameters:
name - radio group name.
radioOption - option to test for.

assertRadioOptionSelected

public void assertRadioOptionSelected(String name,
                                      String radioOption)
Assert that a specific option is selected in a radio group.

Parameters:
name - radio group name.
radioOption - option to test for selection.

assertRadioOptionNotSelected

public void assertRadioOptionNotSelected(String name,
                                         String radioOption)
Assert that a specific option is not selected in a radio group.

Parameters:
name - radio group name.
radioOption - option to test for selection.

assertSelectOptionsPresent

public void assertSelectOptionsPresent(String selectName,
                                       String[] optionLabels)
Assert that given options are present in a select box (by label).

Parameters:
selectName - name of the select element.
optionLabels - option labels.

assertSelectOptionPresent

public void assertSelectOptionPresent(String selectName,
                                      String optionLabel)
Assert that a specific option is present in a select box (by label).

Parameters:
selectName - name of the select element.
optionLabel - option label.

assertSelectOptionValuesPresent

public void assertSelectOptionValuesPresent(String selectName,
                                            String[] optionValues)
Assert that given options are present in a select box (by value).

Parameters:
selectName - name of the select element.
optionValues - option labels.

assertSelectOptionValuePresent

public void assertSelectOptionValuePresent(String selectName,
                                           String optionValue)
Assert that a specific option is present in a select box (by value).

Parameters:
selectName - name of the select element.
optionValue - option value.

assertSelectOptionValueNotPresent

public void assertSelectOptionValueNotPresent(String selectName,
                                              String optionValue)

assertSelectOptionNotPresent

public void assertSelectOptionNotPresent(String selectName,
                                         String optionLabel)
Assert that a specific option is not present in a select box.

Parameters:
selectName - name of the select element.
optionLabel - option label.

assertSelectOptionsEqual

public void assertSelectOptionsEqual(String selectName,
                                     String[] expectedOptions)
Assert that the display values of a select element's options match a given array of strings.

Parameters:
selectName - name of the select element.
expectedOptions - expected labels for the select box.

assertSelectOptionsNotEqual

public void assertSelectOptionsNotEqual(String selectName,
                                        String[] expectedOptions)
Assert that the display values of a select element's options do not match a given array of strings.

Parameters:
selectName - name of the select element.
expectedOptions - expected display values for the select box.

assertSelectOptionValuesEqual

public void assertSelectOptionValuesEqual(String selectName,
                                          String[] expectedValues)
Assert that the values of a select element's options match a given array of strings.

Parameters:
selectName - name of the select element.
expectedValues - expected values for the select box.

assertSelectOptionValuesNotEqual

public void assertSelectOptionValuesNotEqual(String selectName,
                                             String[] optionValues)
Assert that the values of a select element's options do not match a given array of strings.

Parameters:
selectName - name of the select element.
optionValues - expected values for the select box.

assertSelectedOptionsEqual

public void assertSelectedOptionsEqual(String selectName,
                                       String[] labels)
Assert that the currently selected display label(s) of a select box matches given label(s).

Parameters:
selectName - name of the select element.
labels - expected display label(s) of the selected option.

assertSelectedOptionEquals

public void assertSelectedOptionEquals(String selectName,
                                       String option)

assertSelectedOptionValuesEqual

public void assertSelectedOptionValuesEqual(String selectName,
                                            String[] values)
Assert that the currently selected value(s) of a select box matches given value(s).

Parameters:
selectName - name of the select element.
values - expected value(s) of the selected option.

assertSelectedOptionValueEquals

public void assertSelectedOptionValueEquals(String selectName,
                                            String value)
Assert that the currently selected value of a select box matches given value.

Parameters:
selectName - name of the select element.
value - expected value of the selected option.

assertSelectedOptionsMatch

public void assertSelectedOptionsMatch(String selectName,
                                       String[] regexps)
Assert that the currently selected display value(s) of a select box matches a given value(s).

Parameters:
selectName - name of the select element.
regexps - expected display value of the selected option.

assertSelectedOptionMatches

public void assertSelectedOptionMatches(String selectName,
                                        String regexp)

assertSubmitButtonPresent

public void assertSubmitButtonPresent()
Assert that a submit button is present.
A submit button can be the following HTML elements:


assertSubmitButtonPresent

public void assertSubmitButtonPresent(String buttonName)
Assert that a submit button with a given name is present.
A submit button can be the following HTML elements:

Parameters:
buttonName -

assertSubmitButtonNotPresent

public void assertSubmitButtonNotPresent()
Assert that no submit button is present in the current form.
A submit button can be the following HTML elements:


assertSubmitButtonNotPresent

public void assertSubmitButtonNotPresent(String buttonName)
Assert that a submit button with a given name is not present.
A submit button can be the following HTML elements:

Parameters:
buttonName -

assertSubmitButtonPresent

public void assertSubmitButtonPresent(String buttonName,
                                      String buttonValue)
Assert that a submit button with a given name and value is present.
A submit button can be the following HTML elements:

Parameters:
buttonName -
buttonValue -

assertResetButtonPresent

public void assertResetButtonPresent()
Assert that a reset button is present.
A reset button can be the following HTML elements:


assertResetButtonPresent

public void assertResetButtonPresent(String buttonName)
Assert that a reset button with a given name is present.
A reset button can be the following HTML elements:

Parameters:
buttonName -

assertResetButtonNotPresent

public void assertResetButtonNotPresent()
Assert that no reset button is present in the current form.
A reset button can be the following HTML elements:


assertResetButtonNotPresent

public void assertResetButtonNotPresent(String buttonName)
Assert that a reset button with a given name is not present.
A reset button can be the following HTML elements:

Parameters:
buttonName -

assertButtonPresent

public void assertButtonPresent(String buttonId)
Assert that a button with a given id is present in the current window.
A button can be the following HTML elements:

Parameters:
buttonId -

assertButtonPresentWithText

public void assertButtonPresentWithText(String text)
Assert that a button with a given text is present in the current window.

Parameters:
text - Text representation of button content.

assertButtonNotPresentWithText

public void assertButtonNotPresentWithText(String text)
Assert that a button with a given text is not present in the current window.

Parameters:
text - Text representation of button content.

assertButtonNotPresent

public void assertButtonNotPresent(String buttonId)
Assert that a button with a given id is not present in the current window.

Parameters:
buttonId -

assertLinkPresent

public void assertLinkPresent(String linkId)
Assert that a link with a given id is present in the response.

Parameters:
linkId -

assertLinkNotPresent

public void assertLinkNotPresent(String linkId)
Assert that no link with the given id is present in the response.

Parameters:
linkId -

assertLinkPresentWithText

public void assertLinkPresentWithText(String linkText)
Assert that a link containing the supplied text is present.

Parameters:
linkText -

assertLinkNotPresentWithText

public void assertLinkNotPresentWithText(String linkText)
Assert that no link containing the supplied text is present.

Parameters:
linkText -

assertLinkPresentWithText

public void assertLinkPresentWithText(String linkText,
                                      int index)
Assert that a link containing the supplied text is present.

Parameters:
linkText -
index - The 0-based index, when more than one link with the same text is expected.

assertLinkNotPresentWithText

public void assertLinkNotPresentWithText(String linkText,
                                         int index)
Assert that no link containing the supplied text is present.

Parameters:
linkText -
index - The 0-based index, when more than one link with the same text is expected.

assertLinkPresentWithExactText

public void assertLinkPresentWithExactText(String linkText)
Assert that a link containing the Exact text is present.

Parameters:
linkText -

assertLinkNotPresentWithExactText

public void assertLinkNotPresentWithExactText(String linkText)
Assert that no link containing the Exact text is present.

Parameters:
linkText -

assertLinkPresentWithExactText

public void assertLinkPresentWithExactText(String linkText,
                                           int index)
Assert that a link containing the Exact text is present.

Parameters:
linkText -
index - The 0-based index, when more than one link with the same text is expected.

assertLinkNotPresentWithExactText

public void assertLinkNotPresentWithExactText(String linkText,
                                              int index)
Assert that no link containing the Exact text is present.

Parameters:
linkText -
index - The 0-based index, when more than one link with the same text is expected.

assertLinkPresentWithImage

public void assertLinkPresentWithImage(String imageFileName)
Assert that a link containing a specified image is present.

Parameters:
imageFileName - A suffix of the image's filename; for example, to match "images/my_icon.png", you could just pass in "my_icon.png".

assertLinkNotPresentWithImage

public void assertLinkNotPresentWithImage(String imageFileName)
Assert that a link containing a specified image is not present.

Parameters:
imageFileName - A suffix of the image's filename; for example, to match "images/my_icon.png", you could just pass in "my_icon.png".

assertElementPresent

public void assertElementPresent(String anID)
Assert that an element with a given id is present.

Parameters:
anID - element id to test for.

assertElementNotPresent

public void assertElementNotPresent(String anID)
Assert that an element with a given id is not present.

Parameters:
anID - element id to test for.

assertElementPresentByXPath

public void assertElementPresentByXPath(String xpath)
Assert that an element with a given xpath is present.

Parameters:
xpath - element xpath to test for.

assertElementNotPresentByXPath

public void assertElementNotPresentByXPath(String xpath)
Assert that an element with a given xpath is not present.

Parameters:
xpath - element xpath to test for.

assertTextInElement

public void assertTextInElement(String elementID,
                                String text)
Assert that a given element contains specific text.

Parameters:
elementID - id of element to be inspected.
text - to check for.

assertTextNotInElement

public void assertTextNotInElement(String elementID,
                                   String text)

assertMatchInElement

public void assertMatchInElement(String elementID,
                                 String regexp)
Assert that a given element matches a specific regexp.

Parameters:
elementID - id of element to be inspected.
regexp - to match.

assertNoMatchInElement

public void assertNoMatchInElement(String elementID,
                                   String regexp)
Assert that a given element does not match a specific regexp.

Parameters:
elementID - id of element to be inspected.
regexp - to match.

assertWindowPresent

public void assertWindowPresent(String windowName)
Assert that a window with the given name is open.

Parameters:
windowName -

assertWindowPresent

public void assertWindowPresent(int windowID)
Assert that a window with the given ID is open.

Parameters:
windowID - Javascript window ID.

assertWindowPresentWithTitle

public void assertWindowPresentWithTitle(String title)
Assert that at least one window with the given title is open.

Parameters:
title -

assertWindowCountEquals

public void assertWindowCountEquals(int windowCount)
Assert that the number of opened windows equals given value.

Parameters:
windowCount - Window count

assertFramePresent

public void assertFramePresent(String frameNameOrId)
Assert that a frame with the given name or ID is present.

Parameters:
frameNameOrId - Name or ID of the frame. ID is checked first.

assertCookiePresent

public void assertCookiePresent(String cookieName)
Checks to see if a cookie is present in the response.

Parameters:
cookieName - The cookie name

assertCookieValueEquals

public void assertCookieValueEquals(String cookieName,
                                    String expectedValue)
Check to see if a cookie has the given value.

Parameters:
cookieName - The cookie name
expectedValue - The cookie value

assertCookieValueMatch

public void assertCookieValueMatch(String cookieName,
                                   String regexp)
Check to see if a cookie value match the given regexp.

Parameters:
cookieName - The cookie name
regexp - The regexp

getFormElementValue

@Deprecated
public String getFormElementValue(String formElementName)
Deprecated. 


setWorkingForm

public void setWorkingForm(int index)
Begin interaction with a specified form. If form interaction methods are called without explicitly calling this method first, jWebUnit will attempt to determine itself which form is being manipulated.

It is not necessary to call this method if their is only one form on the current page.

Parameters:
index - 0-based index of the form to work with.

setWorkingForm

public void setWorkingForm(String nameOrId)
Begin interaction with a specified form. If form interaction methods are called without explicitly calling this method first, jWebUnit will attempt to determine itself which form is being manipulated.

It is not necessary to call this method if their is only one form on the current page.

Parameters:
nameOrId - name or id of the form to work with.

setWorkingForm

public void setWorkingForm(String nameOrId,
                           int index)
Begin interaction with a specified form. If form interaction methods are called without explicitly calling this method first, jWebUnit will attempt to determine itself which form is being manipulated.

It is not necessary to call this method if their is only one form on the current page.

Parameters:
nameOrId - name or id of the form to work with.
index - The 0-based index, when more than one form with the same name is expected.

setTextField

public void setTextField(String inputName,
                         String value)
Set the value of a text or password input field.

Parameters:
inputName - name of form element.
value - value to set.

checkCheckbox

public void checkCheckbox(String checkBoxName)
Select a specified checkbox. If the checkbox is already checked then the checkbox will stay checked.

Parameters:
checkBoxName - name of checkbox to be selected.

checkCheckbox

public void checkCheckbox(String checkBoxName,
                          String value)
Select a specified checkbox. If the checkbox is already checked then the checkbox will stay checked.

Parameters:
checkBoxName - name of checkbox to be selected.
value - value of checkbox to be selected.

uncheckCheckbox

public void uncheckCheckbox(String checkBoxName)
Deselect a specified checkbox. If the checkbox is already unchecked then the checkbox will stay unchecked.

Parameters:
checkBoxName - name of checkbox to be deselected.

uncheckCheckbox

public void uncheckCheckbox(String checkBoxName,
                            String value)
Deselect a specified checkbox. If the checkbox is already unchecked then the checkbox will stay unchecked.

Parameters:
checkBoxName - name of checkbox to be deselected.
value - value of checkbox to be deselected.

selectOptions

public void selectOptions(String selectName,
                          String[] labels)
Select options with given display labels in a select element.

Parameters:
selectName - name of select element.
labels - labels of options to be selected.

selectOption

public void selectOption(String selectName,
                         String label)
Select an option with a given display label in a select element.

Parameters:
selectName - name of select element.
label - label of option to be selected.

selectOptionsByValues

public void selectOptionsByValues(String selectName,
                                  String[] values)
Select options with given values in a select element.

Parameters:
selectName - name of select element.
values - values of options to be selected.

selectOptionByValue

public void selectOptionByValue(String selectName,
                                String value)
Select an option with a given value in a select element.

Parameters:
selectName - name of select element.
value - values of options to be selected.

submit

public void submit()
Submit form - default submit button will be used (unnamed submit button, or named button if there is only one on the form.


submit

public void submit(String buttonName)
Submit form by pressing named button.

Parameters:
buttonName - Submit button name attribute value.

submit

public void submit(String buttonName,
                   String buttonValue)
Submit the form by pressing the named button with the given value (label). Useful if you have more than one submit button with same name.

Parameters:
buttonName - Submit button name attribute value.
buttonValue - Submit button value attribute value.

reset

public void reset()
Reset the current form using the default reset button. See setWorkingForm(int)for an explanation of how the current form is established.


clickLinkWithText

public void clickLinkWithText(String linkText)
Navigate by selection of a link containing given text.

Parameters:
linkText - Text in the link.

clickLinkWithText

public void clickLinkWithText(String linkText,
                              int index)
Navigate by selecting Nth link containing given text.

Parameters:
linkText - Text in the link.
index - The 0-based index, when more than one link with the same text is expected.

clickLinkWithExactText

public void clickLinkWithExactText(String linkText)
Navigate by selection of a link with the exact given text.

Parameters:
linkText - Text of the link.

clickLinkWithExactText

public void clickLinkWithExactText(String linkText,
                                   int index)
Navigate by selecting Nth link with the exact given text.

Parameters:
linkText - Text of the link.
index - The 0-based index, when more than one link with the same text is expected.

clickButton

public void clickButton(String buttonId)
Click the button with the given id.

Parameters:
buttonId - Button ID attribute value.

clickButtonWithText

public void clickButtonWithText(String buttonValueText)
Clicks a button with text of the value attribute.

Parameters:
buttonValueText - The text of the button (contents of the value attribute).

clickLinkWithImage

public void clickLinkWithImage(String imageFileName)
Navigate by selection of a link with a given image.

Parameters:
imageFileName - A suffix of the image's filename; for example, to match "images/my_icon.png", you could just pass in "my_icon.png".

clickLink

public void clickLink(String linkId)
Navigate by selection of a link with given id.

Parameters:
linkId - id of link

clickRadioOption

public void clickRadioOption(String radioGroup,
                             String radioOption)
Clicks a radio option. Asserts that the radio option exists first. *

Parameters:
radioGroup - name of the radio group.
radioOption - value of the option to check for.

clickElementByXPath

public void clickElementByXPath(String xpath)
Click element with given xpath.

Parameters:
xpath - xpath of the element.

getElementAttributByXPath

public String getElementAttributByXPath(String xpath,
                                        String attribute)
Get the attribute value of the gicen element. For example, if you have img src="bla.gif" alt="toto", getElementAttributByXPath("//img[@src='bla.gif']", "alt") returns "toto"

Parameters:
xpath - XPath of the element.
attribute - Name of the attribute.
Returns:
The value of the attribute.

getElementTextByXPath

public String getElementTextByXPath(String xpath)
Get text of the given element.

Parameters:
xpath - xpath of the element.

gotoWindow

public void gotoWindow(String windowName)
Make a given window active.

Parameters:
windowName - Name of the window.

gotoWindow

public void gotoWindow(int windowID)
Make a given window active.

Parameters:
windowID - Javascript ID of the window

gotoRootWindow

public void gotoRootWindow()
Make the root window active.


gotoWindowByTitle

public void gotoWindowByTitle(String title)
Make first window with the given title active.

Parameters:
title - Title of the window.

gotoFrame

public void gotoFrame(String frameNameOrId)
Make the given frame active.

Parameters:
frameNameOrId - Name or ID of the frame. ID is checked first.

gotoPage

public void gotoPage(String url)
              throws net.sourceforge.jwebunit.exception.TestingEngineResponseException
Go to the given page like if user has typed the URL manually in the browser. Use getTestContext().setBaseUrl(String) to define base URL. Absolute URL should start with "http://", "https://" or "www.".

Parameters:
url - absolute or relative URL (relative to base URL).
Throws:
net.sourceforge.jwebunit.exception.TestingEngineResponseException - If something bad happened (404)

gotoPage

public void gotoPage(UrlBuilder urlBuilder)
              throws net.sourceforge.jwebunit.exception.TestingEngineResponseException
Go to the given page like if user has typed the URL manually in the browser. Use getTestContext().setBaseUrl(String) to define base URL. Absolute URL should start with "http://", "https://" or "www.".

Parameters:
urlBuilder - absolute or relative URL (relative to base URL) builder object.
Throws:
net.sourceforge.jwebunit.exception.TestingEngineResponseException - If something bad happened (404)

dumpCookies

public void dumpCookies()
Print all the cookies to stdout.


getPageSource

public String getPageSource()
Get the source of the HTML page (like in a real browser), or HTTP body for a non HTML content.

Returns:
The HTML content.

getServeurResponse

public String getServeurResponse()
Get the last data sent by the server.

Returns:
HTTP server response.

saveAs

public void saveAs(File f)
Save the last downloaded page (or file) to the disk.

Parameters:
f - The file name.

assertDownloadedFileEquals

public void assertDownloadedFileEquals(URL expected)
Download the current page (or file) and compare it with the given file.

Parameters:
expected - Expected file URL.

dumpHtml

@Deprecated
public void dumpHtml()
Deprecated. Use WebTester.getPageSource()

Dump html of current response to System.out - for debugging purposes.


dumpHtml

@Deprecated
public void dumpHtml(PrintStream stream)
Deprecated. Use WebTester.getPageSource()

Dump html of current response to a specified stream - for debugging purposes.

Parameters:
stream -

dumpTable

public void dumpTable(String tableNameOrId)
Dump the table as the 2D array that is used for assertions - for debugging purposes.

Parameters:
tableNameOrId -

dumpTable

public void dumpTable(String tableNameOrId,
                      PrintStream stream)
Dump the table as the 2D array that is used for assertions - for debugging purposes.

Parameters:
tableNameOrId -
stream -

setScriptingEnabled

public void setScriptingEnabled(boolean value)
Enable or disable Javascript support


setTestingEngineKey

public void setTestingEngineKey(String testingEngineKey)
Set the Testing Engine that you want to use for the tests based on the Testing Engine Key.

Parameters:
testingEngineKey - The testingEngineKey to set.
See Also:
TestingEngineRegistry

getTestingEngineKey

public String getTestingEngineKey()
Gets the Testing Engine Key that is used to find the proper testing engine class (HtmlUnitDialog / SeleniumDialog) for the tests.

Returns:
Returns the testingEngineKey.

setFormElement

@Deprecated
public void setFormElement(String formElementName,
                                      String value)
Deprecated. use setTextField or other methods

Set the value of a form input element.

Parameters:
formElementName - name of form element.
value -

setExpectedJavaScriptAlert

public void setExpectedJavaScriptAlert(String message)
Tell that the given alert box is expected.

Parameters:
message - Message in the alert.

setExpectedJavaScriptAlert

public void setExpectedJavaScriptAlert(String[] messages)
Tell that the given alert boxes are expected in the given order.

Parameters:
messages - Messages in the alerts.

setExpectedJavaScriptConfirm

public void setExpectedJavaScriptConfirm(String message,
                                         boolean action)
Tell that the given confirm box is expected.

Parameters:
message - Message in the confirm.
action - Whether we should click on "OK" (true) or "Cancel" (false)

setExpectedJavaScriptConfirm

public void setExpectedJavaScriptConfirm(String[] messages,
                                         boolean[] actions)
Tell that the given confirm boxes are expected in the given order.

Parameters:
messages - Messages in the confirms.
actions - Whether we should click on "OK" (true) or "Cancel" (false)

setExpectedJavaScriptPrompt

public void setExpectedJavaScriptPrompt(String message,
                                        String input)
Tell that the given prompt box is expected.

Parameters:
message - Message in the prompt.
input - What we should put in the prompt (null if user press Cancel)

setExpectedJavaScriptPrompt

public void setExpectedJavaScriptPrompt(String[] messages,
                                        String[] inputs)
Tell that the given prompt boxes are expected in the given order.

Parameters:
messages - Messages in the prompts.
inputs - What we should put in the prompt (null if user press Cancel)

assertImagePresent

public void assertImagePresent(String imageSrc,
                               String imageAlt)

assertImageValid

public void assertImageValid(String imageSrc,
                             String imageAlt)
See Also:
assertImageValidAndStore(String, String, java.io.File)

assertImageValidAndStore

public void assertImageValidAndStore(String imageSrc,
                                     String imageAlt,
                                     File out)
Asserts that the image with the given src and alt attribute values exist in the page and is an actual reachable image, then saves it as png with the given file name.

Parameters:
imageSrc - as it appears in the html page, i.e. relative to the current page.

getImage

public Image getImage(String imageSrc,
                      String imageAlt)
See Also:
assertImageValidAndStore(String, String, java.io.File)

wrapWithPageSourceOnError

public void wrapWithPageSourceOnError(Runnable runnable)
For use on those few occasions when the exception might be recoverable, but we still want to see what went wrong.

Parameters:
runnable - The original error object
Throws:
junit.framework.AssertionFailedError - A new error with the old one wrapped as a cause


Copyright © 2003-2012 Atlassian. All Rights Reserved.