net.sourceforge.jwebunit.selenium
Class SeleniumTestingEngineImpl

java.lang.Object
  extended by net.sourceforge.jwebunit.selenium.SeleniumTestingEngineImpl
All Implemented Interfaces:
ITestingEngine

public class SeleniumTestingEngineImpl
extends java.lang.Object
implements ITestingEngine

Acts as the wrapper for Selenium access. A testing engine is initialized with a given URL, and maintains conversational state as the dialog progresses through link navigation, form submission, etc.

Author:
Julien Henry

Constructor Summary
SeleniumTestingEngineImpl()
           
 
Method Summary
 void beginAt(java.net.URL aInitialURL, TestContext aTestContext)
          Open the browser at an initial URL.
 void checkCheckbox(java.lang.String checkBoxName)
          Select a specified checkbox.
 void checkCheckbox(java.lang.String checkBoxName, java.lang.String value)
          Select a specified checkbox.
 void clickButton(java.lang.String buttonId)
          Click the indicated button.
 void clickButtonWithText(java.lang.String buttonValueText)
          Clicks a button with text of the value attribute.
 void clickElementByXPath(java.lang.String xpath)
          Click element with given xpath.
 void clickLink(java.lang.String anID)
          Navigate by submitting a request based on a link with a given ID.
 void clickLinkWithExactText(java.lang.String linkText, int index)
          Navigate by clicking a link with the exact specified text.
 void clickLinkWithImage(java.lang.String imageFileName, int index)
          Navigate by submitting a request based on a link with a given image file name.
 void clickLinkWithText(java.lang.String linkText, int index)
          Navigate by submitting a request based on a link containing the specified text.
 void clickRadioOption(java.lang.String radioGroup, java.lang.String radioOptionValue)
          Clicks a radio option.
 void closeBrowser()
          Close the browser and check if there is no pending Javascript alert, confirm or prompt.
 void closeWindow()
          Close the current window.
protected  java.lang.String formSelector()
           
 java.util.Map<java.lang.String,java.lang.String> getAllHeaders()
          Get all headers.
 java.util.List<java.lang.String> getComments()
          Get all the comments in a document, as a list of strings.
 java.util.List getCookies()
          Get all cookies.
 java.lang.String getElementAttributByXPath(java.lang.String xpath, java.lang.String attribut)
          Get attribut value of the given element.
 IElement getElementByID(java.lang.String id)
          Get an element wrapper for a given ID.
 IElement getElementByXPath(java.lang.String xpath)
          Get an element wrapper for a given xpath.
 java.util.List<IElement> getElementsByXPath(java.lang.String xpath)
          Get a list of all elements that match the given xpath.
 java.lang.String getElementTextByXPath(java.lang.String xpath)
          Get text of the given element.
 java.lang.String getHeader(java.lang.String name)
          Get a particular header or null.
 java.lang.String getHiddenFieldValue(java.lang.String paramName)
          Return the current value of a hidden input element with name paramName.
 java.io.InputStream getInputStream()
          Gets the last server response as input stream.
 java.io.InputStream getInputStream(java.net.URL url)
          Gets the input stream for a given URL - can be used to test images or other resources without changing the current navigation context.
 java.lang.String getJavascriptAlert()
           
 java.lang.String getPageSource()
          Return the source of the current page (like in a browser).
 java.lang.String getPageText()
          Return the string representation of the current page, encoded as specified by the current TestContext.
 java.lang.String getPageTitle()
          Return the page title of the current response page, encoded as specified by the current TestContext.
 java.net.URL getPageURL()
          Get the location of the current page.
protected  int getRadioCount(java.lang.String radioGroup)
           
 java.lang.String[] getSelectedOptions(java.lang.String selectName)
          Return the values of the currently selected items in a select box.
 java.lang.String[] getSelectedOptions(java.lang.String selectName, int index)
          Return the values of the currently selected items in the Nth select box with the provided name.
 java.lang.String getSelectedRadio(java.lang.String radioGroup)
          Return the currently selected radio button.
 java.lang.String getSelectOptionLabelForValue(java.lang.String selectName, int index, java.lang.String optionValue)
          Get the label for a given option of the Nth select box with the specified name.
 java.lang.String getSelectOptionLabelForValue(java.lang.String selectName, java.lang.String optionValue)
          Get the label for a given option of a select box.
 java.lang.String getSelectOptionValueForLabel(java.lang.String selectName, int index, java.lang.String optionLabel)
          Get the value for a given option of the Nth select box with the specified name.
 java.lang.String getSelectOptionValueForLabel(java.lang.String selectName, java.lang.String optionLabel)
          Get the value for a given option of a select box.
 java.lang.String[] getSelectOptionValues(java.lang.String selectName)
          Return a string array of select box option values.
 java.lang.String[] getSelectOptionValues(java.lang.String selectName, int index)
          Return a string array of option values for the Nth select box with the specified name.
 java.lang.String getServerResponse()
          Return the response of the server for the current page.
 int getServerResponseCode()
          Get the request response code.
 Table getTable(java.lang.String tableSummaryNameOrId)
          Each framework have it's own way to represent a Table.
 TestContext getTestContext()
           
 java.lang.String getTextFieldValue(java.lang.String paramName)
          Return the current value of a text field with name paramName.
 int getWindowCount()
          Get the number of openend Windows.
 void goBack()
           
 void gotoFrame(java.lang.String frameName)
          Make the frame with the given name or ID active in the current conversation.
 void gotoPage(java.net.URL url)
          Simulate user typing a new URL in the browser.
 void gotoRootWindow()
          Make the root window active.
 void gotoWindow(int windowID)
          Goto window with the given Javascript ID.
 void gotoWindow(java.lang.String windowName)
          Make the window with the given name active.
 void gotoWindowByTitle(java.lang.String title)
          Goto first window with the given title.
 boolean hasButton(java.lang.String buttonId)
          Checks if a button with id is present.
A button can be the following HTML elements: input type=button button type=button
 boolean hasButtonWithText(java.lang.String text)
          Checks if a button with text is present.
A button can be the following HTML elements: input type=button button type=button
 boolean hasDomComment(java.lang.String comment)
           
 boolean hasElement(java.lang.String anID)
          Test if element with given id exists.
 boolean hasElementByXPath(java.lang.String xpath)
          Test if element with given xpath exists.
 boolean hasForm()
          Check whether the current page contains a form.
 boolean hasForm(java.lang.String nameOrID)
          Return true if the current page contains a specific form.
 boolean hasFormParameterNamed(java.lang.String paramName)
          Return true if a form input element is present on the current form.
 boolean hasFrame(java.lang.String frameName)
          Test if the given frame is present.
 boolean hasLink(java.lang.String anId)
          Return true if a link is present in the current response with the specified id.
 boolean hasLinkWithExactText(java.lang.String linkText, int index)
          Return true if a link is present in the current page containing the exact specified text.
 boolean hasLinkWithImage(java.lang.String imageFileName, int index)
          Return true if a link is present with a given image based on filename of image.
 boolean hasLinkWithText(java.lang.String linkText, int index)
          Return true if a link is present in the current response containing the specified text.
 boolean hasRadioOption(java.lang.String radioGroup, java.lang.String radioOptionValue)
          Checks if a radio group contains the indicated option.
 boolean hasResetButton()
          Checks if the current form contains a reset button.
A reset button can be the following HTML elements: input type=reset button type=reset
 boolean hasResetButton(java.lang.String nameOrID)
          Checks if the current form contains a specific reset button.
A reset button can be the following HTML elements: input type=reset button type=reset
 boolean hasSelectOption(java.lang.String selectName, int index, java.lang.String optionLabel)
          Test if the Nth select box has the given option (by label).
 boolean hasSelectOption(java.lang.String selectName, java.lang.String optionLabel)
          Test if a select box has the given option (by label).
 boolean hasSelectOptionValue(java.lang.String selectName, int index, java.lang.String optionValue)
          Test if the Nth select box has the given option (by value).
 boolean hasSelectOptionValue(java.lang.String selectName, java.lang.String optionValue)
          Test if a select box has the given option (by value).
 boolean hasSubmitButton()
          Checks if the current form contains a submit button.
 boolean hasSubmitButton(java.lang.String nameOrID)
          Checks if the current form contains a specific submit button.
A submit button can be the following HTML elements: input type=submit input type=image button type=submit
 boolean hasSubmitButton(java.lang.String nameOrID, java.lang.String value)
          Checks if the current form contains a specific submit button.
A submit button can be the following HTML elements: input type=submit input type=image button type=submit
 boolean hasTable(java.lang.String tableSummaryNameOrId)
          Check if the Table object representing a specified table exists.
 boolean hasWindow(java.lang.String windowName)
          Test if the window with the given name is present.
 boolean hasWindowByTitle(java.lang.String title)
          Test if window with the given title is present.
 boolean isCheckboxSelected(java.lang.String checkBoxName)
          Determines if the checkbox is selected.
 boolean isCheckboxSelected(java.lang.String checkBoxName, java.lang.String checkBoxValue)
          Determines if the checkbox is selected.
 boolean isMatchInElement(java.lang.String elementID, java.lang.String regexp)
          Return true if a given regexp is contained within the specified element.
 boolean isTextInElement(java.lang.String elementID, java.lang.String text)
          Return true if a given string is contained within the specified element.
 void refresh()
           
 void reset()
          Reset the current form with the default reset button.
 void selectOptions(java.lang.String selectName, int index, java.lang.String[] optionsValue)
          Select option(s) of the Nth select box by value.
 void selectOptions(java.lang.String selectName, java.lang.String[] optionsValue)
          Select option(s) of a select box by value.
 void setExpectedJavaScriptAlert(JavascriptAlert[] alerts)
          Tell the testing engine that the given alert boxes are expected in the given order.
 void setExpectedJavaScriptConfirm(JavascriptConfirm[] confirms)
          Tell the testing engine that the given confirm boxes are expected in the given order.
 void setExpectedJavaScriptPrompt(JavascriptPrompt[] prompts)
          Tell the testing engine that the given prompt boxes are expected in the given order.
 void setHiddenField(java.lang.String inputName, java.lang.String text)
          Fill hidden field with the provided text.
 void setIgnoreFailingStatusCodes(boolean ignore)
          Should the tester ignore failing status codes (300+)? Otherwise, failing status codes will throw an exception.
 void setScriptingEnabled(boolean value)
          Enable or disable Javascript support.
 void setTestContext(TestContext testContext)
           
 void setTextField(java.lang.String inputName, java.lang.String text)
          Fill a text, password or textarea field with the provided text.
 void setThrowExceptionOnScriptError(boolean value)
          Set whether or not to throw an exception on Javascript errors.
 void setTimeout(int milliseconds)
          Set the timeout for the request.
 void setWorkingForm(int index)
          Set the form on the current page that the client wishes to work with explicitly by index in the page.
 void setWorkingForm(java.lang.String nameOrId, int index)
          Set the form on the current page that the client wishes to work with explicitly by either the form name or id (match by id is attempted first).
 void submit()
          Submit the current form with the default submit button.
 void submit(java.lang.String nameOrID)
          Submit the current form with the specifed submit button.
 void submit(java.lang.String nameOrID, java.lang.String value)
          Submit the current form with the specifed submit button (by name and value).
 void uncheckCheckbox(java.lang.String checkBoxName)
          Deselect a specified checkbox.
 void uncheckCheckbox(java.lang.String checkBoxName, java.lang.String value)
          Deselect a specified checkbox.
 void unselectOptions(java.lang.String selectName, int index, java.lang.String[] options)
          Unselect option(s) of the Nth select box with the specified name by value.
 void unselectOptions(java.lang.String selectName, java.lang.String[] options)
          Unselect option(s) of a select box by value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeleniumTestingEngineImpl

public SeleniumTestingEngineImpl()
Method Detail

beginAt

public void beginAt(java.net.URL aInitialURL,
                    TestContext aTestContext)
             throws TestingEngineResponseException
Description copied from interface: ITestingEngine
Open the browser at an initial URL.

Specified by:
beginAt in interface ITestingEngine
Parameters:
aInitialURL - Initial URL
aTestContext - Test context
Throws:
TestingEngineResponseException - If something bad happend (404)

checkCheckbox

public void checkCheckbox(java.lang.String checkBoxName,
                          java.lang.String value)
Description copied from interface: ITestingEngine
Select a specified checkbox. If the checkbox is already checked then the checkbox will stay checked.

Specified by:
checkCheckbox in interface ITestingEngine
Parameters:
checkBoxName - name of checkbox to be selected.
value - value of the checkbox (to differenciate checkboxes with the same name).

checkCheckbox

public void checkCheckbox(java.lang.String checkBoxName)
Description copied from interface: ITestingEngine
Select a specified checkbox. If the checkbox is already checked then the checkbox will stay checked.

Specified by:
checkCheckbox in interface ITestingEngine
Parameters:
checkBoxName - name of checkbox to be selected.

clickButton

public void clickButton(java.lang.String buttonId)
Description copied from interface: ITestingEngine
Click the indicated button.
A button can be the following HTML elements:

Specified by:
clickButton in interface ITestingEngine
Parameters:
buttonId - the ID of the button.

clickButtonWithText

public void clickButtonWithText(java.lang.String buttonValueText)
Description copied from interface: ITestingEngine
Clicks a button with text of the value attribute.
A button can be the following HTML elements:

Specified by:
clickButtonWithText in interface ITestingEngine
Parameters:
buttonValueText - the text of the button (contents of the value attribute).

clickElementByXPath

public void clickElementByXPath(java.lang.String xpath)
Description copied from interface: ITestingEngine
Click element with given xpath.

Specified by:
clickElementByXPath in interface ITestingEngine
Parameters:
xpath - xpath of the element.

clickLink

public void clickLink(java.lang.String anID)
Description copied from interface: ITestingEngine
Navigate by submitting a request based on a link with a given ID. A RuntimeException is thrown if no such link can be found.

Specified by:
clickLink in interface ITestingEngine
Parameters:
anID - id of link to be navigated.

clickLinkWithExactText

public void clickLinkWithExactText(java.lang.String linkText,
                                   int index)
Description copied from interface: ITestingEngine
Navigate by clicking a link with the exact specified text. A RuntimeException is thrown if no such link can be found.

Specified by:
clickLinkWithExactText in interface ITestingEngine
Parameters:
linkText - exact text which link to be navigated should contain.
index - The 0-based index, when more than one link with the same text is expected.

clickLinkWithImage

public void clickLinkWithImage(java.lang.String imageFileName,
                               int index)
Description copied from interface: ITestingEngine
Navigate by submitting a request based on a link with a given image file name. A RuntimeException is thrown if no such link can be found.

Specified by:
clickLinkWithImage in interface ITestingEngine
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".
index - The 0-based index, when more than one link with the same text is expected.

clickLinkWithText

public void clickLinkWithText(java.lang.String linkText,
                              int index)
Description copied from interface: ITestingEngine
Navigate by submitting a request based on a link containing the specified text. A RuntimeException is thrown if no such link can be found.

Specified by:
clickLinkWithText in interface ITestingEngine
Parameters:
linkText - text which link to be navigated should contain.
index - The 0-based index, when more than one link with the same text is expected.

clickRadioOption

public void clickRadioOption(java.lang.String radioGroup,
                             java.lang.String radioOptionValue)
Description copied from interface: ITestingEngine
Clicks a radio option. Asserts that the radio option exists first.

Specified by:
clickRadioOption in interface ITestingEngine
Parameters:
radioGroup - name of the radio group.
radioOptionValue - value of the option to check for.

closeBrowser

public void closeBrowser()
                  throws TestingEngineResponseException
Description copied from interface: ITestingEngine
Close the browser and check if there is no pending Javascript alert, confirm or prompt.

Specified by:
closeBrowser in interface ITestingEngine
Throws:
TestingEngineResponseException

closeWindow

public void closeWindow()
Description copied from interface: ITestingEngine
Close the current window.

Specified by:
closeWindow in interface ITestingEngine

getPageSource

public java.lang.String getPageSource()
Description copied from interface: ITestingEngine
Return the source of the current page (like in a browser).

Specified by:
getPageSource in interface ITestingEngine
Returns:
Source of the page (or HTTP Body as String)

getPageText

public java.lang.String getPageText()
Description copied from interface: ITestingEngine
Return the string representation of the current page, encoded as specified by the current TestContext.

Specified by:
getPageText in interface ITestingEngine
Returns:
Visible text in the page.

getPageTitle

public java.lang.String getPageTitle()
Description copied from interface: ITestingEngine
Return the page title of the current response page, encoded as specified by the current TestContext.

Specified by:
getPageTitle in interface ITestingEngine
Returns:
Title of the page.

getCookies

public java.util.List getCookies()
Description copied from interface: ITestingEngine
Get all cookies.

Specified by:
getCookies in interface ITestingEngine
Returns:
List of javax.servlet.http.Cookie.

getSelectedOptions

public java.lang.String[] getSelectedOptions(java.lang.String selectName)
Description copied from interface: ITestingEngine
Return the values of the currently selected items in a select box.

Specified by:
getSelectedOptions in interface ITestingEngine
Parameters:
selectName - name of the select box.

getSelectOptionLabelForValue

public java.lang.String getSelectOptionLabelForValue(java.lang.String selectName,
                                                     java.lang.String optionValue)
Description copied from interface: ITestingEngine
Get the label for a given option of a select box.

Specified by:
getSelectOptionLabelForValue in interface ITestingEngine
Parameters:
selectName - name of the select box.
optionValue - label of the option.

getSelectOptionValueForLabel

public java.lang.String getSelectOptionValueForLabel(java.lang.String selectName,
                                                     java.lang.String optionLabel)
Description copied from interface: ITestingEngine
Get the value for a given option of a select box.

Specified by:
getSelectOptionValueForLabel in interface ITestingEngine
Parameters:
selectName - name of the select box.
optionLabel - label of the option.

getSelectOptionValues

public java.lang.String[] getSelectOptionValues(java.lang.String selectName)
Description copied from interface: ITestingEngine
Return a string array of select box option values. Exemple:


Should return [Component_1_a, Component_1_b, Component_3, Component_4, Component_5]

Specified by:
getSelectOptionValues in interface ITestingEngine
Parameters:
selectName - name of the select box.
Returns:
Array of select options values.

getSelectedOptions

public java.lang.String[] getSelectedOptions(java.lang.String selectName,
                                             int index)
Description copied from interface: ITestingEngine
Return the values of the currently selected items in the Nth select box with the provided name.

Specified by:
getSelectedOptions in interface ITestingEngine
Parameters:
selectName - name of the select box.
index - the 0-based index used when more than one select with the same name is expected.

getSelectOptionLabelForValue

public java.lang.String getSelectOptionLabelForValue(java.lang.String selectName,
                                                     int index,
                                                     java.lang.String optionValue)
Description copied from interface: ITestingEngine
Get the label for a given option of the Nth select box with the specified name.

Specified by:
getSelectOptionLabelForValue in interface ITestingEngine
Parameters:
selectName - name of the select box.
index - the 0-based index used when more than one select with the same name is expected.
optionValue - label of the option.

getSelectOptionValueForLabel

public java.lang.String getSelectOptionValueForLabel(java.lang.String selectName,
                                                     int index,
                                                     java.lang.String optionLabel)
Description copied from interface: ITestingEngine
Get the value for a given option of the Nth select box with the specified name.

Specified by:
getSelectOptionValueForLabel in interface ITestingEngine
Parameters:
selectName - name of the select box.
index - the 0-based index used when more than one select with the same name is expected.
optionLabel - label of the option.

getSelectOptionValues

public java.lang.String[] getSelectOptionValues(java.lang.String selectName,
                                                int index)
Description copied from interface: ITestingEngine
Return a string array of option values for the Nth select box with the specified name.

Specified by:
getSelectOptionValues in interface ITestingEngine
Parameters:
selectName - name of the select box.
index - the 0-based index used when more than one select with the same name is expected.
Returns:
Array of select options values.

getServerResponse

public java.lang.String getServerResponse()
Description copied from interface: ITestingEngine
Return the response of the server for the current page.

Specified by:
getServerResponse in interface ITestingEngine
Returns:
HTTP header & body

goBack

public void goBack()

gotoFrame

public void gotoFrame(java.lang.String frameName)
Description copied from interface: ITestingEngine
Make the frame with the given name or ID active in the current conversation.

Specified by:
gotoFrame in interface ITestingEngine
Parameters:
frameName - Name or ID of the frame. ID is checked first.

gotoPage

public void gotoPage(java.net.URL url)
              throws TestingEngineResponseException
Description copied from interface: ITestingEngine
Simulate user typing a new URL in the browser.

Specified by:
gotoPage in interface ITestingEngine
Parameters:
url - Full URL of the page.
Throws:
TestingEngineResponseException - If something bad happend (404)

gotoRootWindow

public void gotoRootWindow()
Description copied from interface: ITestingEngine
Make the root window active.

Specified by:
gotoRootWindow in interface ITestingEngine

gotoWindow

public void gotoWindow(java.lang.String windowName)
Description copied from interface: ITestingEngine
Make the window with the given name active.

Specified by:
gotoWindow in interface ITestingEngine
Parameters:
windowName - Name of the window

gotoWindowByTitle

public void gotoWindowByTitle(java.lang.String title)
Description copied from interface: ITestingEngine
Goto first window with the given title.

Specified by:
gotoWindowByTitle in interface ITestingEngine
Parameters:
title - Title of the window

hasButton

public boolean hasButton(java.lang.String buttonId)
Description copied from interface: ITestingEngine
Checks if a button with id is present.
A button can be the following HTML elements:

Specified by:
hasButton in interface ITestingEngine
Parameters:
buttonId - the ID of the button.
Returns:
true when the button with text could be found.

hasButtonWithText

public boolean hasButtonWithText(java.lang.String text)
Description copied from interface: ITestingEngine
Checks if a button with text is present.
A button can be the following HTML elements:

Specified by:
hasButtonWithText in interface ITestingEngine
Parameters:
text - the text of the button (contents of the value attribute).
Returns:
true when the button with text could be found.

hasElement

public boolean hasElement(java.lang.String anID)
Description copied from interface: ITestingEngine
Test if element with given id exists.

Specified by:
hasElement in interface ITestingEngine
Parameters:
anID - id of the element.
Returns:
true if element was found.

hasElementByXPath

public boolean hasElementByXPath(java.lang.String xpath)
Description copied from interface: ITestingEngine
Test if element with given xpath exists.

Specified by:
hasElementByXPath in interface ITestingEngine
Parameters:
xpath - xpath of the element.
Returns:
true if element was found.

hasForm

public boolean hasForm()
Description copied from interface: ITestingEngine
Check whether the current page contains a form.

Specified by:
hasForm in interface ITestingEngine
Returns:
true if there is at least a form.

hasForm

public boolean hasForm(java.lang.String nameOrID)
Description copied from interface: ITestingEngine
Return true if the current page contains a specific form.

Specified by:
hasForm in interface ITestingEngine
Parameters:
nameOrID - name of id of the form to check for.
Returns:
true if there is at least a form.

hasFormParameterNamed

public boolean hasFormParameterNamed(java.lang.String paramName)
Description copied from interface: ITestingEngine
Return true if a form input element is present on the current form.

Specified by:
hasFormParameterNamed in interface ITestingEngine
Parameters:
paramName - name of the input element to check for
Returns:
true if there is at least a form parameter.

hasFrame

public boolean hasFrame(java.lang.String frameName)
Description copied from interface: ITestingEngine
Test if the given frame is present.

Specified by:
hasFrame in interface ITestingEngine
Parameters:
frameName - Name or ID of the frame. ID is checked first.
Returns:
true if the frame exists.

hasLink

public boolean hasLink(java.lang.String anId)
Description copied from interface: ITestingEngine
Return true if a link is present in the current response with the specified id.

Specified by:
hasLink in interface ITestingEngine
Parameters:
anId - link id to check for.

hasLinkWithExactText

public boolean hasLinkWithExactText(java.lang.String linkText,
                                    int index)
Description copied from interface: ITestingEngine
Return true if a link is present in the current page containing the exact specified text. Note. This will call String.trim() to trim all leading / trailing spaces. RFE 996031...

Specified by:
hasLinkWithExactText in interface ITestingEngine
Parameters:
linkText - text to check for in links on the response.
index - The 0-based index, when more than one link with the same text is expected.

hasLinkWithImage

public boolean hasLinkWithImage(java.lang.String imageFileName,
                                int index)
Description copied from interface: ITestingEngine
Return true if a link is present with a given image based on filename of image.

Specified by:
hasLinkWithImage in interface ITestingEngine
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".
index - The 0-based index, when more than one link with the same text is expected.

hasLinkWithText

public boolean hasLinkWithText(java.lang.String linkText,
                               int index)
Description copied from interface: ITestingEngine
Return true if a link is present in the current response containing the specified text.

Specified by:
hasLinkWithText in interface ITestingEngine
Parameters:
linkText - text to check for in links on the response.
index - The 0-based index, when more than one link with the same text is expected.

hasRadioOption

public boolean hasRadioOption(java.lang.String radioGroup,
                              java.lang.String radioOptionValue)
Description copied from interface: ITestingEngine
Checks if a radio group contains the indicated option.

Specified by:
hasRadioOption in interface ITestingEngine
Parameters:
radioGroup - name of the radio group.
radioOptionValue - value of the option to check for.

hasSelectOption

public boolean hasSelectOption(java.lang.String selectName,
                               java.lang.String optionLabel)
Description copied from interface: ITestingEngine
Test if a select box has the given option (by label).

Specified by:
hasSelectOption in interface ITestingEngine
Parameters:
selectName - name of the select box.
optionLabel - label of the option.
Returns:
true if a select box has the given option (by label).

hasSelectOptionValue

public boolean hasSelectOptionValue(java.lang.String selectName,
                                    java.lang.String optionValue)
Description copied from interface: ITestingEngine
Test if a select box has the given option (by value).

Specified by:
hasSelectOptionValue in interface ITestingEngine
Parameters:
selectName - name of the select box.
optionValue - value of the option.
Returns:
true if a select box has the given option (by value).

hasSelectOption

public boolean hasSelectOption(java.lang.String selectName,
                               int index,
                               java.lang.String optionLabel)
Description copied from interface: ITestingEngine
Test if the Nth select box has the given option (by label).

Specified by:
hasSelectOption in interface ITestingEngine
Parameters:
selectName - name of the select box.
index - the 0-based index of the select element when multiple select elements are expected.
optionLabel - label of the option.
Returns:
true if a select box has the given option (by label).

hasSelectOptionValue

public boolean hasSelectOptionValue(java.lang.String selectName,
                                    int index,
                                    java.lang.String optionValue)
Description copied from interface: ITestingEngine
Test if the Nth select box has the given option (by value).

Specified by:
hasSelectOptionValue in interface ITestingEngine
Parameters:
selectName - name of the select box.
index - the 0-based index of the select element when multiple select elements are expected.
optionValue - value of the option.
Returns:
true if a select box has the given option (by value).

hasSubmitButton

public boolean hasSubmitButton()
Description copied from interface: ITestingEngine
Checks if the current form contains a submit button.

Specified by:
hasSubmitButton in interface ITestingEngine

hasSubmitButton

public boolean hasSubmitButton(java.lang.String nameOrID,
                               java.lang.String value)
Description copied from interface: ITestingEngine
Checks if the current form contains a specific submit button.
A submit button can be the following HTML elements:
  • input type=submit
  • input type=image
  • button type=submit

Specified by:
hasSubmitButton in interface ITestingEngine
Parameters:
nameOrID - name of id of the button to check for.
value - value of the button

hasSubmitButton

public boolean hasSubmitButton(java.lang.String nameOrID)
Description copied from interface: ITestingEngine
Checks if the current form contains a specific submit button.
A submit button can be the following HTML elements:
  • input type=submit
  • input type=image
  • button type=submit

Specified by:
hasSubmitButton in interface ITestingEngine
Parameters:
nameOrID - name or id of the button to check for.

hasResetButton

public boolean hasResetButton()
Description copied from interface: ITestingEngine
Checks if the current form contains a reset button.
A reset button can be the following HTML elements:
  • input type=reset
  • button type=reset

Specified by:
hasResetButton in interface ITestingEngine

hasResetButton

public boolean hasResetButton(java.lang.String nameOrID)
Description copied from interface: ITestingEngine
Checks if the current form contains a specific reset button.
A reset button can be the following HTML elements:
  • input type=reset
  • button type=reset

Specified by:
hasResetButton in interface ITestingEngine
Parameters:
nameOrID - name or id of the button to check for.

hasTable

public boolean hasTable(java.lang.String tableSummaryNameOrId)
Description copied from interface: ITestingEngine
Check if the Table object representing a specified table exists.

Specified by:
hasTable in interface ITestingEngine
Parameters:
tableSummaryNameOrId - summary, name or id of the table.
Returns:
true if table exists.

hasWindow

public boolean hasWindow(java.lang.String windowName)
Description copied from interface: ITestingEngine
Test if the window with the given name is present.

Specified by:
hasWindow in interface ITestingEngine
Parameters:
windowName - Name of the window.
Returns:
true if the Window exists.

hasWindowByTitle

public boolean hasWindowByTitle(java.lang.String title)
Description copied from interface: ITestingEngine
Test if window with the given title is present.

Specified by:
hasWindowByTitle in interface ITestingEngine
Parameters:
title - Title of the window.
Returns:
true if the Window exists.

isCheckboxSelected

public boolean isCheckboxSelected(java.lang.String checkBoxName)
Description copied from interface: ITestingEngine
Determines if the checkbox is selected.

Specified by:
isCheckboxSelected in interface ITestingEngine
Parameters:
checkBoxName - name of the checkbox.
Returns:
true if the first checkbox with given name is selected.

isCheckboxSelected

public boolean isCheckboxSelected(java.lang.String checkBoxName,
                                  java.lang.String checkBoxValue)
Description copied from interface: ITestingEngine
Determines if the checkbox is selected.

Specified by:
isCheckboxSelected in interface ITestingEngine
Parameters:
checkBoxName - name attribut of the checkbox.
checkBoxValue - value attribut of the checkbox.
Returns:
true if the first checkbox with given name and value is selected.

isMatchInElement

public boolean isMatchInElement(java.lang.String elementID,
                                java.lang.String regexp)
Description copied from interface: ITestingEngine
Return true if a given regexp is contained within the specified element.

Specified by:
isMatchInElement in interface ITestingEngine
Parameters:
elementID - Id of element to inspect.
regexp - regexp to match.
Returns:
true if a match is found.

isTextInElement

public boolean isTextInElement(java.lang.String elementID,
                               java.lang.String text)
Description copied from interface: ITestingEngine
Return true if a given string is contained within the specified element.

Specified by:
isTextInElement in interface ITestingEngine
Parameters:
elementID - ID of element to inspect.
text - text to check for.
Returns:
true if text was found.

refresh

public void refresh()

reset

public void reset()
Description copied from interface: ITestingEngine
Reset the current form with the default reset button. See #getFormfor an explanation of how the current form is established.
A reset button can be the following HTML elements:
  • input type=reset
  • button type=reset

Specified by:
reset in interface ITestingEngine

selectOptions

public void selectOptions(java.lang.String selectName,
                          java.lang.String[] optionsValue)
Description copied from interface: ITestingEngine
Select option(s) of a select box by value.

Specified by:
selectOptions in interface ITestingEngine
Parameters:
selectName - name of the select box.
optionsValue - values of the options to select.

selectOptions

public void selectOptions(java.lang.String selectName,
                          int index,
                          java.lang.String[] optionsValue)
Description copied from interface: ITestingEngine
Select option(s) of the Nth select box by value.

Specified by:
selectOptions in interface ITestingEngine
Parameters:
selectName - name of the select box.
index - the 0-based index of the select element when multiple select elements are expected.
optionsValue - values of the options to select.

setScriptingEnabled

public void setScriptingEnabled(boolean value)
Description copied from interface: ITestingEngine
Enable or disable Javascript support.

Specified by:
setScriptingEnabled in interface ITestingEngine
Parameters:
value - true to enable Javascript.

setThrowExceptionOnScriptError

public void setThrowExceptionOnScriptError(boolean value)
Description copied from interface: ITestingEngine
Set whether or not to throw an exception on Javascript errors.

Specified by:
setThrowExceptionOnScriptError in interface ITestingEngine
Parameters:
value - true to throw an exception on Javascript errors.

setTextField

public void setTextField(java.lang.String inputName,
                         java.lang.String text)
Description copied from interface: ITestingEngine
Fill a text, password or textarea field with the provided text.

Specified by:
setTextField in interface ITestingEngine
Parameters:
inputName - name of the text, password or textarea element
text - value to type in the field.

setHiddenField

public void setHiddenField(java.lang.String inputName,
                           java.lang.String text)
Description copied from interface: ITestingEngine
Fill hidden field with the provided text.

Specified by:
setHiddenField in interface ITestingEngine
Parameters:
inputName - name of the hidden element
text - value to set in the hidden field.

setWorkingForm

public void setWorkingForm(java.lang.String nameOrId,
                           int index)
Description copied from interface: ITestingEngine
Set the form on the current page that the client wishes to work with explicitly by either the form name or id (match by id is attempted first).

Specified by:
setWorkingForm in interface ITestingEngine
Parameters:
nameOrId - name or id of the form to be worked with.
index - The 0-based index, when more than one form with the same name is expected.

submit

public void submit()
Description copied from interface: ITestingEngine
Submit the current form with the default submit button. See #getFormfor an explanation of how the current form is established.
A submit button can be the following HTML elements:
  • input type=submit
  • input type=image
  • button type=submit

Specified by:
submit in interface ITestingEngine

submit

public void submit(java.lang.String nameOrID,
                   java.lang.String value)
Description copied from interface: ITestingEngine
Submit the current form with the specifed submit button (by name and value). See #getFormfor an explanation of how the current form is established.
A submit button can be the following HTML elements:
  • input type=submit
  • input type=image
  • button type=submit

Specified by:
submit in interface ITestingEngine
Parameters:
nameOrID - name of the button to use for submission.
value - value/label of the button to use for submission

submit

public void submit(java.lang.String nameOrID)
Description copied from interface: ITestingEngine
Submit the current form with the specifed submit button. See #getFormfor an explanation of how the current form is established.
A submit button can be the following HTML elements:
  • input type=submit
  • input type=image
  • button type=submit

Specified by:
submit in interface ITestingEngine
Parameters:
nameOrID - name of the button to use for submission.

uncheckCheckbox

public void uncheckCheckbox(java.lang.String checkBoxName,
                            java.lang.String value)
Description copied from interface: ITestingEngine
Deselect a specified checkbox. If the checkbox is already unchecked then the checkbox will stay unchecked.

Specified by:
uncheckCheckbox in interface ITestingEngine
Parameters:
checkBoxName - name of checkbox to be deselected.
value - value of the checkbox (to differenciate checkboxes with the same name).

uncheckCheckbox

public void uncheckCheckbox(java.lang.String checkBoxName)
Description copied from interface: ITestingEngine
Deselect a specified checkbox. If the checkbox is already unchecked then the checkbox will stay unchecked.

Specified by:
uncheckCheckbox in interface ITestingEngine
Parameters:
checkBoxName - name of checkbox to be deselected.

unselectOptions

public void unselectOptions(java.lang.String selectName,
                            java.lang.String[] options)
Description copied from interface: ITestingEngine
Unselect option(s) of a select box by value.

Specified by:
unselectOptions in interface ITestingEngine
Parameters:
selectName - name of the select box.
options - vaules of the options to unselect.

unselectOptions

public void unselectOptions(java.lang.String selectName,
                            int index,
                            java.lang.String[] options)
Description copied from interface: ITestingEngine
Unselect option(s) of the Nth select box with the specified name by value.

Specified by:
unselectOptions in interface ITestingEngine
Parameters:
selectName - name of the select box.
index - the 0-based index of the select element when multiple select elements are expected.
options - vaules of the options to unselect.

getTestContext

public TestContext getTestContext()

setTestContext

public void setTestContext(TestContext testContext)

getTable

public Table getTable(java.lang.String tableSummaryNameOrId)
Description copied from interface: ITestingEngine
Each framework have it's own way to represent a Table. Testing engines are responsible for converting to the unified JWebUnit format.

Specified by:
getTable in interface ITestingEngine
Parameters:
tableSummaryNameOrId - summary, name or id of the table to return.
Returns:
unified JWebUnit representation of a table.

formSelector

protected java.lang.String formSelector()

getWindowCount

public int getWindowCount()
Description copied from interface: ITestingEngine
Get the number of openend Windows.

Specified by:
getWindowCount in interface ITestingEngine
Returns:
Number of openend Windows.

gotoWindow

public void gotoWindow(int windowID)
Description copied from interface: ITestingEngine
Goto window with the given Javascript ID.

Specified by:
gotoWindow in interface ITestingEngine
Parameters:
windowID - Javascript ID of the window

getTextFieldValue

public java.lang.String getTextFieldValue(java.lang.String paramName)
Description copied from interface: ITestingEngine
Return the current value of a text field with name paramName. Text fields are input text, input password and textarea

Specified by:
getTextFieldValue in interface ITestingEngine
Parameters:
paramName - name of the text field element.
Returns:
Text content of the text field.

getHiddenFieldValue

public java.lang.String getHiddenFieldValue(java.lang.String paramName)
Description copied from interface: ITestingEngine
Return the current value of a hidden input element with name paramName.

Specified by:
getHiddenFieldValue in interface ITestingEngine
Parameters:
paramName - name of the hidden input element.
Returns:
Value of the hidden input.

getJavascriptAlert

public java.lang.String getJavascriptAlert()
                                    throws ElementNotFoundException
Throws:
ElementNotFoundException

getElementAttributByXPath

public java.lang.String getElementAttributByXPath(java.lang.String xpath,
                                                  java.lang.String attribut)
Description copied from interface: ITestingEngine
Get attribut value of the given element. For example, if you have img src="bla.gif" alt="toto", getElementAttributByXPath("//img[@src='bla.gif']", "alt") returns "toto"

Specified by:
getElementAttributByXPath in interface ITestingEngine
Parameters:
xpath - xpath of the element.
attribut - name of the attribut.
Returns:
Attribut value or null if the element is not found.

getElementTextByXPath

public java.lang.String getElementTextByXPath(java.lang.String xpath)
Description copied from interface: ITestingEngine
Get text of the given element.

Specified by:
getElementTextByXPath in interface ITestingEngine
Parameters:
xpath - xpath of the element.

getInputStream

public java.io.InputStream getInputStream()
Description copied from interface: ITestingEngine
Gets the last server response as input stream.

Specified by:
getInputStream in interface ITestingEngine

getInputStream

public java.io.InputStream getInputStream(java.net.URL url)
                                   throws TestingEngineResponseException
Description copied from interface: ITestingEngine
Gets the input stream for a given URL - can be used to test images or other resources without changing the current navigation context.

Specified by:
getInputStream in interface ITestingEngine
Parameters:
url - the url to the resource
Throws:
TestingEngineResponseException

getPageURL

public java.net.URL getPageURL()
Description copied from interface: ITestingEngine
Get the location of the current page.

Specified by:
getPageURL in interface ITestingEngine
Returns:
an URL.

getSelectedRadio

public java.lang.String getSelectedRadio(java.lang.String radioGroup)
Description copied from interface: ITestingEngine
Return the currently selected radio button.

Specified by:
getSelectedRadio in interface ITestingEngine
Parameters:
radioGroup - name of the radio group.
Returns:
value of the selected radio.

getRadioCount

protected int getRadioCount(java.lang.String radioGroup)

setExpectedJavaScriptAlert

public void setExpectedJavaScriptAlert(JavascriptAlert[] alerts)
                                throws ExpectedJavascriptAlertException
Description copied from interface: ITestingEngine
Tell the testing engine that the given alert boxes are expected in the given order.

Specified by:
setExpectedJavaScriptAlert in interface ITestingEngine
Parameters:
alerts - Expected alerts.
Throws:
ExpectedJavascriptAlertException - If there are still unconsummed alert since a previous call of this method.

setExpectedJavaScriptConfirm

public void setExpectedJavaScriptConfirm(JavascriptConfirm[] confirms)
                                  throws ExpectedJavascriptConfirmException
Description copied from interface: ITestingEngine
Tell the testing engine that the given confirm boxes are expected in the given order.

Specified by:
setExpectedJavaScriptConfirm in interface ITestingEngine
Parameters:
confirms - Expected confirms.
Throws:
ExpectedJavascriptConfirmException - If there are still unconsummed confirm since a previous call of this method.

setExpectedJavaScriptPrompt

public void setExpectedJavaScriptPrompt(JavascriptPrompt[] prompts)
                                 throws ExpectedJavascriptPromptException
Description copied from interface: ITestingEngine
Tell the testing engine that the given prompt boxes are expected in the given order.

Specified by:
setExpectedJavaScriptPrompt in interface ITestingEngine
Parameters:
prompts - Expected prompts.
Throws:
ExpectedJavascriptPromptException - If there are still unconsummed prompt since a previous call of this method.

setWorkingForm

public void setWorkingForm(int index)
Description copied from interface: ITestingEngine
Set the form on the current page that the client wishes to work with explicitly by index in the page.

Specified by:
setWorkingForm in interface ITestingEngine
Parameters:
index - The 0-based index, when more than one form with the same name is expected.

getElementByXPath

public IElement getElementByXPath(java.lang.String xpath)
Description copied from interface: ITestingEngine
Get an element wrapper for a given xpath.

Specified by:
getElementByXPath in interface ITestingEngine
Parameters:
xpath - XPath to evaluate
Returns:
The element if found
See Also:
ITestingEngine.getElementsByXPath(String)

getElementByID

public IElement getElementByID(java.lang.String id)
Description copied from interface: ITestingEngine
Get an element wrapper for a given ID.

Specified by:
getElementByID in interface ITestingEngine
Parameters:
id - element ID to find
Returns:
The element if found

getElementsByXPath

public java.util.List<IElement> getElementsByXPath(java.lang.String xpath)
Description copied from interface: ITestingEngine
Get a list of all elements that match the given xpath.

Specified by:
getElementsByXPath in interface ITestingEngine
Parameters:
xpath - XPath to evaluate
Returns:
List of all elements found
See Also:
ITestingEngine.getElementByXPath(String)

getServerResponseCode

public int getServerResponseCode()
Description copied from interface: ITestingEngine
Get the request response code.

Specified by:
getServerResponseCode in interface ITestingEngine
Returns:
The request response code.

getAllHeaders

public java.util.Map<java.lang.String,java.lang.String> getAllHeaders()
Description copied from interface: ITestingEngine
Get all headers.

Specified by:
getAllHeaders in interface ITestingEngine
Returns:
The header values stored in a map.

getHeader

public java.lang.String getHeader(java.lang.String name)
Description copied from interface: ITestingEngine
Get a particular header or null.

Specified by:
getHeader in interface ITestingEngine
Parameters:
name - The header name
Returns:
The first header value or null

setIgnoreFailingStatusCodes

public void setIgnoreFailingStatusCodes(boolean ignore)
Description copied from interface: ITestingEngine
Should the tester ignore failing status codes (300+)? Otherwise, failing status codes will throw an exception.

Specified by:
setIgnoreFailingStatusCodes in interface ITestingEngine

hasDomComment

public boolean hasDomComment(java.lang.String comment)

getComments

public java.util.List<java.lang.String> getComments()
Description copied from interface: ITestingEngine
Get all the comments in a document, as a list of strings.

Specified by:
getComments in interface ITestingEngine

setTimeout

public void setTimeout(int milliseconds)
Description copied from interface: ITestingEngine
Set the timeout for the request. A timeout of 0 means an infinite timeout.

Specified by:
setTimeout in interface ITestingEngine
Parameters:
milliseconds - the milliseconds in which to timeout, or 0 for infinite wait (the default).


Copyright © 2002-2011 SourceForge. All Rights Reserved.