net.sourceforge.jwebunit.htmlunit
Class HtmlUnitTestingEngineImpl

java.lang.Object
  extended by net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl
All Implemented Interfaces:
ITestingEngine

public class HtmlUnitTestingEngineImpl
extends java.lang.Object
implements ITestingEngine

Acts as the wrapper for HtmlUnit 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
HtmlUnitTestingEngineImpl()
          Initializes default HtmlUnit testing engine implementation.
 
Method Summary
 void beginAt(java.net.URL initialURL, TestContext context)
          Begin a dialog with an initial URL and test client context.
 void checkCheckbox(java.lang.String checkBoxName)
          Select a specified checkbox.
 void checkCheckbox(java.lang.String checkBoxName, java.lang.String value)
           
 void clickButton(java.lang.String buttonId)
          Click the indicated button (input type=button).
 void clickButtonWithText(java.lang.String buttonValueText)
          Clicks the first button that contains the specified text as its label.
 void clickElementByXPath(java.lang.String 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)
           
 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)
           
 void clickRadioOption(java.lang.String radioGroup, java.lang.String radioOption)
          Clicks a radio option.
 void closeBrowser()
          Close the browser and check that all expected Javascript alerts, confirms and prompts have been taken care of.
 void closeWindow()
          Close the current window.
 java.util.Map<java.lang.String,java.lang.String> getAllHeaders()
           
 com.gargoylesoftware.htmlunit.html.ClickableElement getButtonWithText(java.lang.String buttonValueText)
          Returns the first button that contains the specified text as its label.
 java.util.List<java.lang.String> getComments()
          Get all the comments in a document, as a list of strings.
 java.util.List<javax.servlet.http.Cookie> getCookies()
           
 java.lang.String getCurrentPageTitle()
          Return the page title of the current response page, encoded as specified by the current TestContext.
 com.gargoylesoftware.htmlunit.BrowserVersion getDefaultBrowserVersion()
          An alternative to setting the user agent string manually is to provide it with all the information for a complete browser version.
 java.lang.String getElementAttributByXPath(java.lang.String xpath, java.lang.String attribut)
           
 IElement getElementByID(java.lang.String id)
           
 IElement getElementByXPath(java.lang.String xpath)
           
 java.util.List<IElement> getElementsByXPath(java.lang.String xpath)
           
 java.lang.String getElementTextByXPath(java.lang.String xpath)
           
 java.lang.String getHeader(java.lang.String name)
           
 java.lang.String getHiddenFieldValue(java.lang.String paramName)
          Return the current value of a hidden input element with name paramName.
 com.gargoylesoftware.htmlunit.html.HtmlTable getHtmlTable(java.lang.String tableSummaryOrId)
          Return the HttpUnit WebTable object representing a specified table in the current response.
 java.io.InputStream getInputStream()
           
 java.io.InputStream getInputStream(java.net.URL resourceUrl)
           
 java.lang.String getPageSource()
           
 java.lang.String getPageText()
           
 java.lang.String getPageTitle()
           
 java.net.URL getPageURL()
           
 com.gargoylesoftware.htmlunit.html.HtmlResetInput getResetButton(java.lang.String buttonName)
           
 java.lang.String[] getSelectedOptions(java.lang.String selectName)
           
 java.lang.String[] getSelectedOptions(java.lang.String selectName, int index)
           
 java.lang.String getSelectedRadio(java.lang.String radioGroup)
           
 java.lang.String getSelectOptionLabelForValue(java.lang.String selectName, int index, java.lang.String value)
           
 java.lang.String getSelectOptionLabelForValue(java.lang.String selectName, java.lang.String value)
           
 java.lang.String getSelectOptionValueForLabel(java.lang.String selectName, int index, java.lang.String label)
           
 java.lang.String getSelectOptionValueForLabel(java.lang.String selectName, java.lang.String label)
           
 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 the Nth select box option values.
 java.lang.String getServerResponse()
           
 int getServerResponseCode()
           
 com.gargoylesoftware.htmlunit.html.ClickableElement getSubmitButton(java.lang.String buttonName)
          Return the HtmlUnit submit button with a given name.
 com.gargoylesoftware.htmlunit.html.ClickableElement getSubmitButton(java.lang.String buttonName, java.lang.String buttonValue)
          Return the HtmlUnit submit button with a given name and value.
 Table getTable(java.lang.String tableSummaryOrId)
           
 java.lang.String getTextFieldValue(java.lang.String paramName)
          Return the current value of a text input element with name paramName.
 com.gargoylesoftware.htmlunit.WebResponse getWebResponse()
          Get the last WebResponse from HtmlUnit.
 int getWindowCount()
           
 void gotoFrame(java.lang.String frameNameOrId)
          
 void gotoPage(java.net.URL initialURL)
          Go to a particular page.
 void gotoRootWindow()
          Make the root window in the current conversation active.
 void gotoWindow(int windowID)
           
 void gotoWindow(java.lang.String windowName)
          Make the window with the given name in the current conversation active.
 void gotoWindowByTitle(java.lang.String title)
          Goto first window with the given title.
 boolean hasButton(java.lang.String buttonId)
          Returns if the button identified by buttonId is present.
 boolean hasButtonWithText(java.lang.String text)
          Checks whether a button containing the specified text as its label exists.
 boolean hasElement(java.lang.String anID)
           
 boolean hasElementByXPath(java.lang.String xpath)
           
 boolean hasForm()
          Return true if the current response contains a form.
 boolean hasForm(java.lang.String nameOrID)
          Return true if the current response contains a specific form.
 boolean hasFormParameterNamed(java.lang.String paramName)
           
 boolean hasFormSelectNamed(java.lang.String selectName)
          Return true if a form parameter (input element) is present on the current response.
 boolean hasFrame(java.lang.String frameNameOrId)
          
 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)
           
 boolean hasLinkWithImage(java.lang.String imageFileName, int index)
           
 boolean hasLinkWithText(java.lang.String linkText, int index)
          Return true if a link is present in the current response containing the specified text (note that HttpUnit uses contains rather than an exact match - if this is a problem consider using ids on the links to uniquely identify them).
 boolean hasRadioOption(java.lang.String radioGroup, java.lang.String radioOption)
          Return true if a radio group contains the indicated option.
 boolean hasResetButton()
           
 boolean hasResetButton(java.lang.String buttonName)
           
 boolean hasSelectOption(java.lang.String selectName, int index, java.lang.String optionLabel)
          Return true if the Nth select box contains the indicated option.
 boolean hasSelectOption(java.lang.String selectName, java.lang.String optionLabel)
          Return true if a select box contains the indicated option.
 boolean hasSelectOptionValue(java.lang.String selectName, int index, java.lang.String optionValue)
          Return true if the Nth select box contains the indicated option.
 boolean hasSelectOptionValue(java.lang.String selectName, java.lang.String optionValue)
          Return true if a select box contains the indicated option.
 boolean hasSubmitButton()
          
 boolean hasSubmitButton(java.lang.String buttonName)
          
 boolean hasSubmitButton(java.lang.String buttonName, java.lang.String buttonValue)
          
 boolean hasTable(java.lang.String tableSummaryOrId)
           
 boolean hasWindow(java.lang.String windowName)
           
 boolean hasWindowByTitle(java.lang.String title)
           
 boolean isCheckboxSelected(java.lang.String checkBoxName)
           
 boolean isCheckboxSelected(java.lang.String checkBoxName, java.lang.String checkBoxValue)
           
 boolean isIgnoreFailingStatusCodes()
           
 boolean isMatchInElement(java.lang.String elementID, java.lang.String regexp)
           
 boolean isTextInElement(java.lang.String elementID, java.lang.String text)
           
 boolean isTextInTable(java.lang.String tableSummaryOrId, java.lang.String text)
          Return true if given text is present in a specified table of the response.
 void reset()
          Reset the current form.
 void selectOptions(java.lang.String selectName, int index, java.lang.String[] options)
          Select the specified set of options in the select element with the provided name.
 void selectOptions(java.lang.String selectName, java.lang.String[] options)
          Select the specified set of options in the select element with the provided name.
 void setDefaultBrowserVersion(com.gargoylesoftware.htmlunit.BrowserVersion defaultBrowserVersion)
          An alternative to setting the user agent string manually is to provide it with all the information for a complete browser version.
 void setExpectedJavaScriptAlert(JavascriptAlert[] alerts)
           
 void setExpectedJavaScriptConfirm(JavascriptConfirm[] confirms)
           
 void setExpectedJavaScriptPrompt(JavascriptPrompt[] prompts)
           
 void setHiddenField(java.lang.String fieldName, java.lang.String text)
          Set a form hidden element to the provided value.
 void setIgnoreFailingStatusCodes(boolean ignore)
           
 void setScriptingEnabled(boolean value)
           
 void setTextField(java.lang.String paramName, java.lang.String text)
          Set a form text, password input element or textarea to the provided value.
 void setThrowExceptionOnScriptError(boolean value)
           
 void setTimeout(int milliseconds)
           
 void setWorkingForm(int index)
          
 void setWorkingForm(java.lang.String nameOrId, int index)
          
 void submit()
          Submit the current form with the default submit button.
 void submit(java.lang.String buttonName)
          Submit the current form with the specified submit button.
 void submit(java.lang.String buttonName, java.lang.String buttonValue)
          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)
           
 void unselectOptions(java.lang.String selectName, int index, java.lang.String[] options)
           
 void unselectOptions(java.lang.String selectName, java.lang.String[] options)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlUnitTestingEngineImpl

public HtmlUnitTestingEngineImpl()
Initializes default HtmlUnit testing engine implementation.

Method Detail

beginAt

public void beginAt(java.net.URL initialURL,
                    TestContext context)
             throws TestingEngineResponseException
Begin a dialog with an initial URL and test client context.

Specified by:
beginAt in interface ITestingEngine
Parameters:
initialURL - absolute url at which to begin dialog.
context - contains context information for the test client.
Throws:
TestingEngineResponseException

closeBrowser

public void closeBrowser()
                  throws ExpectedJavascriptAlertException,
                         ExpectedJavascriptConfirmException,
                         ExpectedJavascriptPromptException
Close the browser and check that all expected Javascript alerts, confirms and prompts have been taken care of.

Specified by:
closeBrowser in interface ITestingEngine
Throws:
ExpectedJavascriptAlertException
ExpectedJavascriptConfirmException
ExpectedJavascriptPromptException

gotoPage

public void gotoPage(java.net.URL initialURL)
              throws TestingEngineResponseException
Go to a particular page.

Specified by:
gotoPage in interface ITestingEngine
Throws:
TestingEngineResponseException - if an error response code is encountered and ignoreFailingStatusCodes is not enabled.

setScriptingEnabled

public void setScriptingEnabled(boolean value)
Specified by:
setScriptingEnabled in interface ITestingEngine
See Also:
IJWebUnitDialog

setThrowExceptionOnScriptError

public void setThrowExceptionOnScriptError(boolean value)
Specified by:
setThrowExceptionOnScriptError in interface ITestingEngine

getCookies

public java.util.List<javax.servlet.http.Cookie> getCookies()
Specified by:
getCookies in interface ITestingEngine

hasWindow

public boolean hasWindow(java.lang.String windowName)
Specified by:
hasWindow in interface ITestingEngine

hasWindowByTitle

public boolean hasWindowByTitle(java.lang.String title)
Specified by:
hasWindowByTitle in interface ITestingEngine

gotoWindow

public void gotoWindow(java.lang.String windowName)
Make the window with the given name in the current conversation active.

Specified by:
gotoWindow in interface ITestingEngine
Parameters:
windowName -

gotoWindow

public void gotoWindow(int windowID)
Specified by:
gotoWindow in interface ITestingEngine

getWindowCount

public int getWindowCount()
Specified by:
getWindowCount in interface ITestingEngine

gotoWindowByTitle

public void gotoWindowByTitle(java.lang.String title)
Goto first window with the given title.

Specified by:
gotoWindowByTitle in interface ITestingEngine
Parameters:
title -

closeWindow

public void closeWindow()
Close the current window.

Specified by:
closeWindow in interface ITestingEngine

hasFrame

public boolean hasFrame(java.lang.String frameNameOrId)

Specified by:
hasFrame in interface ITestingEngine

gotoFrame

public void gotoFrame(java.lang.String frameNameOrId)

Specified by:
gotoFrame in interface ITestingEngine

setWorkingForm

public void setWorkingForm(int index)

Specified by:
setWorkingForm in interface ITestingEngine

setWorkingForm

public void setWorkingForm(java.lang.String nameOrId,
                           int index)

Specified by:
setWorkingForm in interface ITestingEngine

hasForm

public boolean hasForm()
Return true if the current response contains a form.

Specified by:
hasForm in interface ITestingEngine

hasForm

public boolean hasForm(java.lang.String nameOrID)
Return true if the current response contains a specific form.

Specified by:
hasForm in interface ITestingEngine
Parameters:
nameOrID - name of id of the form to check for.

hasFormParameterNamed

public boolean hasFormParameterNamed(java.lang.String paramName)
Specified by:
hasFormParameterNamed in interface ITestingEngine

getTextFieldValue

public java.lang.String getTextFieldValue(java.lang.String paramName)
Return the current value of a text input element with name paramName.

Specified by:
getTextFieldValue in interface ITestingEngine
Parameters:
paramName - name of the input element. TODO: Find a way to handle multiple text input element with same name.

getHiddenFieldValue

public java.lang.String getHiddenFieldValue(java.lang.String paramName)
Return the current value of a hidden input element with name paramName.

Specified by:
getHiddenFieldValue in interface ITestingEngine
Parameters:
paramName - name of the input element. TODO: Find a way to handle multiple hidden input element with same name.

setTextField

public void setTextField(java.lang.String paramName,
                         java.lang.String text)
Set a form text, password input element or textarea to the provided value.

Specified by:
setTextField in interface ITestingEngine
Parameters:
fieldName - name of the input element or textarea
text - parameter value to submit for the element.

setHiddenField

public void setHiddenField(java.lang.String fieldName,
                           java.lang.String text)
Set a form hidden element to the provided value.

Specified by:
setHiddenField in interface ITestingEngine
Parameters:
fieldName - name of the hidden input element
paramValue - parameter value to submit for the element.

getSelectOptionValues

public java.lang.String[] getSelectOptionValues(java.lang.String selectName)
Return a string array of select box option values.

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

getSelectOptionValues

public java.lang.String[] getSelectOptionValues(java.lang.String selectName,
                                                int index)
Return a string array of the Nth select box option values.

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

getSelectedOptions

public java.lang.String[] getSelectedOptions(java.lang.String selectName)
Specified by:
getSelectedOptions in interface ITestingEngine

getSelectedOptions

public java.lang.String[] getSelectedOptions(java.lang.String selectName,
                                             int index)
Specified by:
getSelectedOptions in interface ITestingEngine

getSelectOptionValueForLabel

public java.lang.String getSelectOptionValueForLabel(java.lang.String selectName,
                                                     java.lang.String label)
Specified by:
getSelectOptionValueForLabel in interface ITestingEngine

getSelectOptionValueForLabel

public java.lang.String getSelectOptionValueForLabel(java.lang.String selectName,
                                                     int index,
                                                     java.lang.String label)
Specified by:
getSelectOptionValueForLabel in interface ITestingEngine

getSelectOptionLabelForValue

public java.lang.String getSelectOptionLabelForValue(java.lang.String selectName,
                                                     java.lang.String value)
Specified by:
getSelectOptionLabelForValue in interface ITestingEngine

getSelectOptionLabelForValue

public java.lang.String getSelectOptionLabelForValue(java.lang.String selectName,
                                                     int index,
                                                     java.lang.String value)
Specified by:
getSelectOptionLabelForValue in interface ITestingEngine

getPageURL

public java.net.URL getPageURL()
Specified by:
getPageURL in interface ITestingEngine

getPageSource

public java.lang.String getPageSource()
Specified by:
getPageSource in interface ITestingEngine

getPageTitle

public java.lang.String getPageTitle()
Specified by:
getPageTitle in interface ITestingEngine

getPageText

public java.lang.String getPageText()
Specified by:
getPageText in interface ITestingEngine

getServerResponse

public java.lang.String getServerResponse()
Specified by:
getServerResponse in interface ITestingEngine

getInputStream

public java.io.InputStream getInputStream()
Specified by:
getInputStream in interface ITestingEngine

getInputStream

public java.io.InputStream getInputStream(java.net.URL resourceUrl)
                                   throws TestingEngineResponseException
Specified by:
getInputStream in interface ITestingEngine
Throws:
TestingEngineResponseException

getComments

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

Specified by:
getComments in interface ITestingEngine

getCurrentPageTitle

public java.lang.String getCurrentPageTitle()
Return the page title of the current response page, encoded as specified by the current TestContext.


hasFormSelectNamed

public boolean hasFormSelectNamed(java.lang.String selectName)
Return true if a form parameter (input element) is present on the current response.

Parameters:
selectName - name of the input element to check for

getSubmitButton

public com.gargoylesoftware.htmlunit.html.ClickableElement getSubmitButton(java.lang.String buttonName)
Return the HtmlUnit submit button with a given name.

Parameters:
buttonName - name of button.
Returns:
the button

getResetButton

public com.gargoylesoftware.htmlunit.html.HtmlResetInput getResetButton(java.lang.String buttonName)

getSubmitButton

public com.gargoylesoftware.htmlunit.html.ClickableElement getSubmitButton(java.lang.String buttonName,
                                                                           java.lang.String buttonValue)
Return the HtmlUnit submit button with a given name and value.

Parameters:
buttonName - button name.
buttonValue - button value.
Returns:
HtmlSubmitInput, HtmlImageInput or HtmlButton

hasSubmitButton

public boolean hasSubmitButton()

Specified by:
hasSubmitButton in interface ITestingEngine

hasSubmitButton

public boolean hasSubmitButton(java.lang.String buttonName)

Specified by:
hasSubmitButton in interface ITestingEngine

hasSubmitButton

public boolean hasSubmitButton(java.lang.String buttonName,
                               java.lang.String buttonValue)

Specified by:
hasSubmitButton in interface ITestingEngine

hasResetButton

public boolean hasResetButton()
Specified by:
hasResetButton in interface ITestingEngine

hasResetButton

public boolean hasResetButton(java.lang.String buttonName)
Specified by:
hasResetButton in interface ITestingEngine

hasButtonWithText

public boolean hasButtonWithText(java.lang.String text)
Checks whether a button containing the specified text as its label exists. For HTML input tags of type submit, reset, or button, this checks the value attribute. For HTML button tags, this checks the element's content by converting it to text.

Specified by:
hasButtonWithText in interface ITestingEngine
Parameters:
text - the text of the button (between <button></button>) or the value of the "value" attribute.
Returns:
true when the button with text could be found.

getButtonWithText

public com.gargoylesoftware.htmlunit.html.ClickableElement getButtonWithText(java.lang.String buttonValueText)
Returns the first button that contains the specified text as its label. For HTML input tags of type submit, reset, or button, this checks the value attribute. For HTML button tags, this checks the element's content by converting it to text.

Parameters:
buttonValueText - the text of the button (between <button></button>) or the value of the "value" attribute.
Returns:
the ClickableElement with the specified text or null if no such button is found.

hasButton

public boolean hasButton(java.lang.String buttonId)
Returns if the button identified by buttonId is present.

Specified by:
hasButton in interface ITestingEngine
Parameters:
buttonId - the id of the button
Returns:
true when the button was found.

isCheckboxSelected

public boolean isCheckboxSelected(java.lang.String checkBoxName)
Specified by:
isCheckboxSelected in interface ITestingEngine

isCheckboxSelected

public boolean isCheckboxSelected(java.lang.String checkBoxName,
                                  java.lang.String checkBoxValue)
Specified by:
isCheckboxSelected in interface ITestingEngine

isTextInTable

public boolean isTextInTable(java.lang.String tableSummaryOrId,
                             java.lang.String text)
Return true if given text is present in a specified table of the response.

Parameters:
tableSummaryOrId - table summary or id to inspect for expected text.
text - expected text to check for.

getTable

public Table getTable(java.lang.String tableSummaryOrId)
Specified by:
getTable in interface ITestingEngine

getHtmlTable

public com.gargoylesoftware.htmlunit.html.HtmlTable getHtmlTable(java.lang.String tableSummaryOrId)
Return the HttpUnit WebTable object representing a specified table in the current response. Null is returned if a parsing exception occurs looking for the table or no table with the id or summary could be found.

Parameters:
tableSummaryOrId - summary or id of the table to return.

hasTable

public boolean hasTable(java.lang.String tableSummaryOrId)
Specified by:
hasTable in interface ITestingEngine

submit

public void submit()
Submit the current form with the default submit button. See getForm()for an explanation of how the current form is established.

Specified by:
submit in interface ITestingEngine

submit

public void submit(java.lang.String buttonName)
Submit the current form with the specified submit button. See getForm()for an explanation of how the current form is established.

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

submit

public void submit(java.lang.String buttonName,
                   java.lang.String buttonValue)
Submit the current form with the specifed submit button (by name and value). See getForm()for an explanation of how the current form is established.

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

reset

public void reset()
Reset the current form. See getForm()for an explanation of how the current form is established.

Specified by:
reset in interface ITestingEngine

hasLinkWithText

public boolean hasLinkWithText(java.lang.String linkText,
                               int index)
Return true if a link is present in the current response containing the specified text (note that HttpUnit uses contains rather than an exact match - if this is a problem consider using ids on the links to uniquely identify them).

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.

hasLinkWithExactText

public boolean hasLinkWithExactText(java.lang.String linkText,
                                    int index)
Specified by:
hasLinkWithExactText in interface ITestingEngine

hasLinkWithImage

public boolean hasLinkWithImage(java.lang.String imageFileName,
                                int index)
Specified by:
hasLinkWithImage in interface ITestingEngine

hasLink

public boolean hasLink(java.lang.String anId)
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.

clickLinkWithText

public void clickLinkWithText(java.lang.String linkText,
                              int index)
Specified by:
clickLinkWithText in interface ITestingEngine

clickLinkWithExactText

public void clickLinkWithExactText(java.lang.String linkText,
                                   int index)
Specified by:
clickLinkWithExactText in interface ITestingEngine

checkCheckbox

public void checkCheckbox(java.lang.String checkBoxName)
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 deselected.

checkCheckbox

public void checkCheckbox(java.lang.String checkBoxName,
                          java.lang.String value)
Specified by:
checkCheckbox in interface ITestingEngine

uncheckCheckbox

public void uncheckCheckbox(java.lang.String checkBoxName)
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.

uncheckCheckbox

public void uncheckCheckbox(java.lang.String checkBoxName,
                            java.lang.String value)
Specified by:
uncheckCheckbox in interface ITestingEngine

clickRadioOption

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

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

clickLink

public void clickLink(java.lang.String anID)
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.

clickLinkWithImage

public void clickLinkWithImage(java.lang.String imageFileName,
                               int index)
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".

hasElement

public boolean hasElement(java.lang.String anID)
Specified by:
hasElement in interface ITestingEngine

hasElementByXPath

public boolean hasElementByXPath(java.lang.String xpath)
Specified by:
hasElementByXPath in interface ITestingEngine

clickElementByXPath

public void clickElementByXPath(java.lang.String xpath)
Specified by:
clickElementByXPath in interface ITestingEngine

getElementAttributByXPath

public java.lang.String getElementAttributByXPath(java.lang.String xpath,
                                                  java.lang.String attribut)
Specified by:
getElementAttributByXPath in interface ITestingEngine

getElementTextByXPath

public java.lang.String getElementTextByXPath(java.lang.String xpath)
Specified by:
getElementTextByXPath in interface ITestingEngine

clickButton

public void clickButton(java.lang.String buttonId)
Click the indicated button (input type=button).

Specified by:
clickButton in interface ITestingEngine
Parameters:
buttonId -

clickButtonWithText

public void clickButtonWithText(java.lang.String buttonValueText)
Clicks the first button that contains the specified text as its label. For HTML input tags of type submit, reset, or button, this checks the value attribute. For HTML button tags, this checks the element's content by converting it to text. or an HTML <button> tag.

Specified by:
clickButtonWithText in interface ITestingEngine

hasRadioOption

public boolean hasRadioOption(java.lang.String radioGroup,
                              java.lang.String radioOption)
Return true if a radio group contains the indicated option.

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

getSelectedRadio

public java.lang.String getSelectedRadio(java.lang.String radioGroup)
Specified by:
getSelectedRadio in interface ITestingEngine

hasSelectOption

public boolean hasSelectOption(java.lang.String selectName,
                               java.lang.String optionLabel)
Return true if a select box contains the indicated option.

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

hasSelectOptionValue

public boolean hasSelectOptionValue(java.lang.String selectName,
                                    java.lang.String optionValue)
Return true if a select box contains the indicated option.

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

selectOptions

public void selectOptions(java.lang.String selectName,
                          java.lang.String[] options)
Select the specified set of options in the select element with the provided name.

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

hasSelectOption

public boolean hasSelectOption(java.lang.String selectName,
                               int index,
                               java.lang.String optionLabel)
Return true if the Nth select box contains the indicated option.

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.

hasSelectOptionValue

public boolean hasSelectOptionValue(java.lang.String selectName,
                                    int index,
                                    java.lang.String optionValue)
Return true if the Nth select box contains the indicated option.

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.

selectOptions

public void selectOptions(java.lang.String selectName,
                          int index,
                          java.lang.String[] options)
Select the specified set of options in the select element with the provided name.

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.
options - set of options to select.

unselectOptions

public void unselectOptions(java.lang.String selectName,
                            java.lang.String[] options)
Specified by:
unselectOptions in interface ITestingEngine

unselectOptions

public void unselectOptions(java.lang.String selectName,
                            int index,
                            java.lang.String[] options)
Specified by:
unselectOptions in interface ITestingEngine

isTextInElement

public boolean isTextInElement(java.lang.String elementID,
                               java.lang.String text)
Specified by:
isTextInElement in interface ITestingEngine

isMatchInElement

public boolean isMatchInElement(java.lang.String elementID,
                                java.lang.String regexp)
Specified by:
isMatchInElement in interface ITestingEngine

gotoRootWindow

public void gotoRootWindow()
Make the root window in the current conversation active.

Specified by:
gotoRootWindow in interface ITestingEngine

setExpectedJavaScriptAlert

public void setExpectedJavaScriptAlert(JavascriptAlert[] alerts)
                                throws ExpectedJavascriptAlertException
Specified by:
setExpectedJavaScriptAlert in interface ITestingEngine
Throws:
ExpectedJavascriptAlertException

setExpectedJavaScriptConfirm

public void setExpectedJavaScriptConfirm(JavascriptConfirm[] confirms)
                                  throws ExpectedJavascriptConfirmException
Specified by:
setExpectedJavaScriptConfirm in interface ITestingEngine
Throws:
ExpectedJavascriptConfirmException

setExpectedJavaScriptPrompt

public void setExpectedJavaScriptPrompt(JavascriptPrompt[] prompts)
                                 throws ExpectedJavascriptPromptException
Specified by:
setExpectedJavaScriptPrompt in interface ITestingEngine
Throws:
ExpectedJavascriptPromptException

getElementByXPath

public IElement getElementByXPath(java.lang.String xpath)
Specified by:
getElementByXPath in interface ITestingEngine

getElementByID

public IElement getElementByID(java.lang.String id)
Specified by:
getElementByID in interface ITestingEngine

getElementsByXPath

public java.util.List<IElement> getElementsByXPath(java.lang.String xpath)
Specified by:
getElementsByXPath in interface ITestingEngine

getServerResponseCode

public int getServerResponseCode()
Specified by:
getServerResponseCode in interface ITestingEngine

getWebResponse

public com.gargoylesoftware.htmlunit.WebResponse getWebResponse()
Get the last WebResponse from HtmlUnit.


isIgnoreFailingStatusCodes

public boolean isIgnoreFailingStatusCodes()

setIgnoreFailingStatusCodes

public void setIgnoreFailingStatusCodes(boolean ignore)
Specified by:
setIgnoreFailingStatusCodes in interface ITestingEngine

getHeader

public java.lang.String getHeader(java.lang.String name)
Specified by:
getHeader in interface ITestingEngine

getAllHeaders

public java.util.Map<java.lang.String,java.lang.String> getAllHeaders()
Specified by:
getAllHeaders in interface ITestingEngine

getDefaultBrowserVersion

public com.gargoylesoftware.htmlunit.BrowserVersion getDefaultBrowserVersion()
An alternative to setting the user agent string manually is to provide it with all the information for a complete browser version.

Returns:
The default browser version
See Also:
BrowserVersion

setDefaultBrowserVersion

public void setDefaultBrowserVersion(com.gargoylesoftware.htmlunit.BrowserVersion defaultBrowserVersion)
An alternative to setting the user agent string manually is to provide it with all the information for a complete browser version.

Parameters:
the - browser version to set as default for this engine instance
See Also:
BrowserVersion

setTimeout

public void setTimeout(int milliseconds)
Specified by:
setTimeout in interface ITestingEngine


Copyright © 2002-2009 SourceForge. All Rights Reserved.