public class HtmlUnitTestingEngineImpl extends Object implements ITestingEngine
Constructor and Description |
---|
HtmlUnitTestingEngineImpl()
Initializes default HtmlUnit testing engine implementation.
|
Modifier and Type | Method and Description |
---|---|
void |
beginAt(URL initialURL,
TestContext context)
Begin a dialog with an initial URL and test client context.
|
void |
checkCheckbox(String checkBoxName)
Select a specified checkbox.
|
void |
checkCheckbox(String checkBoxName,
String value)
Select a specified checkbox.
|
void |
clickButton(String buttonId)
Click the indicated button (input type=button).
|
void |
clickButtonWithText(String buttonValueText)
Clicks the first button that contains the specified text as its label.
|
void |
clickElementByXPath(String xpath)
Click element with given xpath.
|
void |
clickLink(String anID)
Navigate by submitting a request based on a link with a given ID.
|
void |
clickLinkWithExactText(String linkText,
int index)
Navigate by clicking a link with the exact specified text.
|
void |
clickLinkWithImage(String imageFileName,
int index)
Navigate by submitting a request based on a link with a given image file name.
|
void |
clickLinkWithText(String linkText,
int index)
Navigate by submitting a request based on a link containing the specified text.
|
void |
clickRadioOption(String radioGroup,
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.
|
protected WebClient |
createWebClient()
Create the
WebClient that will be used for this test. |
Map<String,String> |
getAllHeaders()
Deprecated.
|
HtmlElement |
getButtonWithText(String buttonValueText)
Returns the first button that contains the specified text as its label.
|
List<String> |
getComments()
Get all the comments in a document, as a list of strings.
|
List<javax.servlet.http.Cookie> |
getCookies()
Get all cookies.
|
protected HtmlPage |
getCurrentPage() |
String |
getCurrentPageTitle()
Return the page title of the current response page, encoded as specified by the current
TestContext . |
WebWindow |
getCurrentWindow()
Return the currently opened window (issue 2697234).
|
BrowserVersion |
getDefaultBrowserVersion()
An alternative to setting the
user agent string manually
is to provide it with all the information for a complete browser version. |
String |
getElementAttributByXPath(String xpath,
String attribut)
Get attribut value of the given element.
|
IElement |
getElementByID(String id)
Get an element wrapper for a given ID.
|
IElement |
getElementByXPath(String xpath)
Get an element wrapper for a given xpath.
|
List<IElement> |
getElementsByXPath(String xpath)
Get a list of all elements that match the given xpath.
|
String |
getElementTextByXPath(String xpath)
Get text of the given element.
|
protected HtmlForm |
getForm()
Return the current form active for the dialog.
|
String |
getHeader(String name)
Get a particular header or null.
|
String |
getHiddenFieldValue(String paramName)
Return the current value of a hidden input element with name
paramName . |
InputStream |
getInputStream()
Gets the last server response as input stream.
|
InputStream |
getInputStream(URL resourceUrl)
Gets the input stream for a given URL - can be used to test images or other resources without changing the current
navigation context.
|
String |
getPageSource()
Return the source of the current page (like in a browser).
|
String |
getPageText()
Return the string representation of the current page, encoded as specified by the current
TestContext . |
String |
getPageTitle()
Return the page title of the current response page, encoded as specified by the current
TestContext . |
URL |
getPageURL()
Get the location of the current page.
|
HtmlElement |
getResetButton(String buttonName) |
List<HttpHeader> |
getResponseHeaders()
Get all response headers.
|
String[] |
getSelectedOptions(String selectName)
Return the values of the currently selected items in a select box.
|
String[] |
getSelectedOptions(String selectName,
int index)
Return the values of the currently selected items in the Nth select box
with the provided name.
|
String |
getSelectedRadio(String radioGroup)
Return the currently selected radio button.
|
String |
getSelectOptionLabelForValue(String selectName,
int index,
String value)
Get the label for a given option of the Nth select box with the
specified name.
|
String |
getSelectOptionLabelForValue(String selectName,
String value)
Get the label for a given option of a select box.
|
String |
getSelectOptionValueForLabel(String selectName,
int index,
String label)
Get the value for a given option of the Nth select box with
the specified name.
|
String |
getSelectOptionValueForLabel(String selectName,
String label)
Get the value for a given option of a select box.
|
String[] |
getSelectOptionValues(String selectName)
Return a string array of select box option values.
|
String[] |
getSelectOptionValues(String selectName,
int index)
Return a string array of the Nth select box option values.
|
String |
getServerResponse()
Return the response of the server for the current page.
|
int |
getServerResponseCode()
Get the request response code.
|
HtmlElement |
getSubmitButton(String buttonName)
Return the HtmlUnit submit button with a given name.
|
HtmlElement |
getSubmitButton(String buttonName,
String buttonValue)
Return the HtmlUnit submit button with a given name and value.
|
Table |
getTable(String tableSummaryNameOrId)
Each framework have it's own way to represent a Table.
|
protected TestContext |
getTestContext() |
String |
getTextFieldValue(String paramName)
Return the current value of a text input element with name
paramName . |
WebClient |
getWebClient()
Return the current web client (issue 2697234).
|
WebResponse |
getWebResponse()
Get the last WebResponse from HtmlUnit.
|
WebWindow |
getWindow(String windowName)
Return the window with the given name in the current conversation.
|
int |
getWindowCount()
Get the number of opened Windows.
|
void |
gotoFrame(String frameNameOrId)
Make the frame with the given name or ID active in the current conversation.
|
void |
gotoPage(URL initialURL)
Go to a particular page.
|
void |
gotoRootWindow()
Make the root window active.
|
void |
gotoWindow(int windowID)
Goto window with the given Javascript ID.
|
void |
gotoWindow(String windowName)
Make the window with the given name in the current conversation active.
|
void |
gotoWindowByTitle(String title)
Goto first window with the given title.
|
boolean |
hasButton(String buttonId)
Returns if the button identified by
buttonId is present. |
boolean |
hasButtonWithText(String text)
Checks whether a button containing the specified text as its label exists.
|
boolean |
hasElement(String anID)
Test if element with given id exists.
|
boolean |
hasElementByXPath(String xpath)
Test if element with given xpath exists.
|
boolean |
hasForm()
Return true if the current response contains a form.
|
boolean |
hasForm(String nameOrID)
Return true if the current response contains a specific form.
|
boolean |
hasForm(String nameOrID,
int index)
Return true if the current page contains a specific form.
|
boolean |
hasFormParameterNamed(String paramName)
Return true if a form input element is present on the current form.
|
boolean |
hasFormSelectNamed(String selectName)
Return true if a form parameter (input element) is present on the current response.
|
boolean |
hasFrame(String frameNameOrId)
Test if the given frame is present.
|
boolean |
hasLink(String anId)
Return true if a link is present in the current response with the specified id.
|
boolean |
hasLinkWithExactText(String linkText,
int index)
Return true if a link is present in the current page containing the exact specified text.
|
boolean |
hasLinkWithImage(String imageFileName,
int index)
Return true if a link is present with a given image based on filename of image.
|
boolean |
hasLinkWithText(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(String radioGroup,
String radioOption)
Return true if a radio group contains the indicated option.
|
boolean |
hasResetButton()
Checks if the current form contains a reset button.
|
boolean |
hasResetButton(String buttonName)
Checks if the current form contains a specific reset button.
|
boolean |
hasSelectOption(String selectName,
int index,
String optionLabel)
Return true if the Nth select box contains the indicated option.
|
boolean |
hasSelectOption(String selectName,
String optionLabel)
Return true if a select box contains the indicated option.
|
boolean |
hasSelectOptionValue(String selectName,
int index,
String optionValue)
Return true if the Nth select box contains the indicated option.
|
boolean |
hasSelectOptionValue(String selectName,
String optionValue)
Return true if a select box contains the indicated option.
|
boolean |
hasSubmitButton()
Checks if the current form contains a submit button.
|
boolean |
hasSubmitButton(String buttonName)
Checks if the current form contains a specific submit button.
|
boolean |
hasSubmitButton(String buttonName,
String buttonValue)
Checks if the current form contains a specific submit button.
|
boolean |
hasTable(String tableSummaryNameOrId)
Check if the Table object representing a specified table exists.
|
boolean |
hasWindow(String windowName)
Test if the window with the given name is present.
|
boolean |
hasWindowByTitle(String title)
Test if window with the given title is present.
|
boolean |
isCheckboxSelected(String checkBoxName)
Determines if the checkbox is selected.
|
boolean |
isCheckboxSelected(String checkBoxName,
String checkBoxValue)
Determines if the checkbox is selected.
|
boolean |
isMatchInElement(String elementID,
String regexp)
Return true if a given regexp is contained within the specified element.
|
boolean |
isTextInElement(String elementID,
String text)
Return true if a given string is contained within the specified element.
|
boolean |
isTextInTable(String tableSummaryOrId,
String text)
Return true if given text is present in a specified table of the response.
|
void |
reset()
Reset the current form.
|
void |
selectOptions(String selectName,
int index,
String[] options)
Select the specified set of options in the select element
with the provided name.
|
void |
selectOptions(String selectName,
String[] options)
Select the specified set of options in the select element
with the provided name.
|
void |
setDefaultBrowserVersion(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)
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(String fieldName,
String text)
Set a form hidden element to the provided value.
|
void |
setIgnoreFailingStatusCodes(boolean ignore)
Should the tester ignore failing status codes (300+)?
|
void |
setRefreshHandler(RefreshHandler handler) |
void |
setScriptingEnabled(boolean value)
Enable or disable Javascript support.
|
void |
setTextField(String paramName,
String text)
Set a form text, password input element or textarea to the provided value.
|
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(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(String buttonName)
Submit the current form with the specified submit button.
|
void |
submit(String buttonName,
String buttonValue)
Submit the current form with the specifed submit button (by name and value).
|
void |
uncheckCheckbox(String checkBoxName)
Deselect a specified checkbox.
|
void |
uncheckCheckbox(String checkBoxName,
String value)
Deselect a specified checkbox.
|
void |
unselectOptions(String selectName,
int index,
String[] options)
Unselect option(s) of the Nth select box with the specified name
by value.
|
void |
unselectOptions(String selectName,
String[] options)
Unselect option(s) of a select box by value.
|
public HtmlUnitTestingEngineImpl()
public void beginAt(URL initialURL, TestContext context) throws TestingEngineResponseException
beginAt
in interface ITestingEngine
initialURL
- absolute url at which to begin dialog.context
- contains context information for the test client.TestingEngineResponseException
public void closeBrowser() throws ExpectedJavascriptAlertException, ExpectedJavascriptConfirmException, ExpectedJavascriptPromptException
closeBrowser
in interface ITestingEngine
ExpectedJavascriptAlertException
- If there is pending Javascript alert
ITestingEngine.setExpectedJavaScriptAlert(JavascriptAlert[])
ExpectedJavascriptConfirmException
- If there is pending Javascript confirm
ITestingEngine.setExpectedJavaScriptConfirm(JavascriptConfirm[])
ExpectedJavascriptPromptException
- If there is pending Javascript prompt
ITestingEngine.setExpectedJavaScriptPrompt(JavascriptPrompt[])
public void gotoPage(URL initialURL) throws TestingEngineResponseException
gotoPage
in interface ITestingEngine
initialURL
- Full URL of the page.TestingEngineResponseException
- if an error response code is encountered
and ignoreFailingStatusCodes is not enabled.public void setScriptingEnabled(boolean value)
ITestingEngine
setScriptingEnabled
in interface ITestingEngine
value
- true to enable Javascript.net.sourceforge.jwebunit.api.IJWebUnitDialog#setScriptingEnabled(boolean)
public void setThrowExceptionOnScriptError(boolean value)
ITestingEngine
setThrowExceptionOnScriptError
in interface ITestingEngine
value
- true to throw an exception on Javascript errors.public List<javax.servlet.http.Cookie> getCookies()
ITestingEngine
getCookies
in interface ITestingEngine
public boolean hasWindow(String windowName)
ITestingEngine
hasWindow
in interface ITestingEngine
windowName
- Name of the window.public boolean hasWindowByTitle(String title)
ITestingEngine
hasWindowByTitle
in interface ITestingEngine
title
- Title of the window.public void gotoWindow(String windowName)
gotoWindow
in interface ITestingEngine
windowName
- public void gotoWindow(int windowID)
ITestingEngine
gotoWindow
in interface ITestingEngine
windowID
- Javascript ID of the windowpublic int getWindowCount()
ITestingEngine
getWindowCount
in interface ITestingEngine
public void gotoWindowByTitle(String title)
gotoWindowByTitle
in interface ITestingEngine
title
- public void closeWindow()
closeWindow
in interface ITestingEngine
public boolean hasFrame(String frameNameOrId)
hasFrame
in interface ITestingEngine
frameNameOrId
- Name or ID of the frame. ID is checked first.public void gotoFrame(String frameNameOrId)
gotoFrame
in interface ITestingEngine
frameNameOrId
- Name or ID of the frame. ID is checked first.public void setWorkingForm(int index)
setWorkingForm
in interface ITestingEngine
index
- The 0-based index, when more than one form with the same name is expected.public void setWorkingForm(String nameOrId, int index)
setWorkingForm
in interface ITestingEngine
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.public boolean hasForm()
hasForm
in interface ITestingEngine
public boolean hasForm(String nameOrID)
hasForm
in interface ITestingEngine
nameOrID
- name of id of the form to check for.public boolean hasForm(String nameOrID, int index)
ITestingEngine
hasForm
in interface ITestingEngine
nameOrID
- name of id of the form to check for.index
- The 0-based index, when more than one form with the same name is expected.public boolean hasFormParameterNamed(String paramName)
ITestingEngine
hasFormParameterNamed
in interface ITestingEngine
paramName
- name of the input element to check forpublic String getTextFieldValue(String paramName)
paramName
.getTextFieldValue
in interface ITestingEngine
paramName
- name of the input element. TODO: Find a way to handle multiple text input element with same
name.public String getHiddenFieldValue(String paramName)
paramName
.getHiddenFieldValue
in interface ITestingEngine
paramName
- name of the input element. TODO: Find a way to handle multiple hidden input element with same
name.public void setTextField(String paramName, String text)
setTextField
in interface ITestingEngine
fieldName
- name of the input element or textareatext
- parameter value to submit for the element.public void setHiddenField(String fieldName, String text)
setHiddenField
in interface ITestingEngine
fieldName
- name of the hidden input elementparamValue
- parameter value to submit for the element.public String[] getSelectOptionValues(String selectName)
getSelectOptionValues
in interface ITestingEngine
selectName
- name of the select box.public String[] getSelectOptionValues(String selectName, int index)
getSelectOptionValues
in interface ITestingEngine
selectName
- name of the select box.index
- the 0-based index when more than one
select with the same name is expected.public String[] getSelectedOptions(String selectName)
ITestingEngine
getSelectedOptions
in interface ITestingEngine
selectName
- name of the select box.public String[] getSelectedOptions(String selectName, int index)
ITestingEngine
getSelectedOptions
in interface ITestingEngine
selectName
- name of the select box.index
- the 0-based index used when more than one select with
the same name is expected.public String getSelectOptionValueForLabel(String selectName, String label)
ITestingEngine
getSelectOptionValueForLabel
in interface ITestingEngine
selectName
- name of the select box.label
- label of the option.public String getSelectOptionValueForLabel(String selectName, int index, String label)
ITestingEngine
getSelectOptionValueForLabel
in interface ITestingEngine
selectName
- name of the select box.index
- the 0-based index used when more than one select with
the same name is expected.label
- label of the option.public String getSelectOptionLabelForValue(String selectName, String value)
ITestingEngine
getSelectOptionLabelForValue
in interface ITestingEngine
selectName
- name of the select box.value
- label of the option.public String getSelectOptionLabelForValue(String selectName, int index, String value)
ITestingEngine
getSelectOptionLabelForValue
in interface ITestingEngine
selectName
- name of the select box.index
- the 0-based index used when more than one select with
the same name is expected.value
- label of the option.public URL getPageURL()
ITestingEngine
getPageURL
in interface ITestingEngine
public String getPageSource()
ITestingEngine
getPageSource
in interface ITestingEngine
public String getPageTitle()
ITestingEngine
TestContext
.getPageTitle
in interface ITestingEngine
public String getPageText()
ITestingEngine
TestContext
.getPageText
in interface ITestingEngine
public String getServerResponse()
ITestingEngine
getServerResponse
in interface ITestingEngine
public InputStream getInputStream()
ITestingEngine
getInputStream
in interface ITestingEngine
public InputStream getInputStream(URL resourceUrl) throws TestingEngineResponseException
ITestingEngine
getInputStream
in interface ITestingEngine
resourceUrl
- the url to the resourceTestingEngineResponseException
protected WebClient createWebClient()
WebClient
that will be used for this test.
Subclasses should only override this method if they need to override
the default WebClient
.
Also see issue 2697234.
WebClient
public WebWindow getWindow(String windowName)
windowName
- WebWindowNotFoundException
- if the window could not be foundpublic WebWindow getCurrentWindow()
public WebClient getWebClient()
public List<String> getComments()
getComments
in interface ITestingEngine
public String getCurrentPageTitle()
TestContext
.protected HtmlForm getForm()
Return the current form active for the dialog.
The active form can also be explicitly set by setWorkingForm(int)
.
If this method is called without the form having been implicitly or explicitly set, it will attempt to return the default first form on the page.
UnableToSetFormException
- This runtime assertion failure will be raised if there is no form on the
response.protected HtmlPage getCurrentPage()
public boolean hasFormSelectNamed(String selectName)
selectName
- name of the input element to check forpublic HtmlElement getSubmitButton(String buttonName)
buttonName
- name of button.public HtmlElement getResetButton(String buttonName)
public HtmlElement getSubmitButton(String buttonName, String buttonValue)
buttonName
- button name.buttonValue
- button value.public boolean hasSubmitButton()
hasSubmitButton
in interface ITestingEngine
public boolean hasSubmitButton(String buttonName)
hasSubmitButton
in interface ITestingEngine
buttonName
- name or id of the button to check for.public boolean hasSubmitButton(String buttonName, String buttonValue)
hasSubmitButton
in interface ITestingEngine
buttonName
- name of id of the button to check for.buttonValue
- value of the buttonpublic boolean hasResetButton()
ITestingEngine
hasResetButton
in interface ITestingEngine
public boolean hasResetButton(String buttonName)
ITestingEngine
hasResetButton
in interface ITestingEngine
buttonName
- name or id of the button to check for.public boolean hasButtonWithText(String text)
This method does not check whether the button is currently visible to the client.
hasButtonWithText
in interface ITestingEngine
text
- the text of the button (between <button></button>)
or the value of the "value" attribute.true
when the button with text could be found.public HtmlElement getButtonWithText(String buttonValueText)
This method does not check whether the button is currently visible to the client.
buttonValueText
- the text of the button (between <button></button>)
or the value of the "value" attribute.public boolean hasButton(String buttonId)
buttonId
is present.hasButton
in interface ITestingEngine
buttonId
- the id of the buttontrue
when the button was found.public boolean isCheckboxSelected(String checkBoxName)
ITestingEngine
isCheckboxSelected
in interface ITestingEngine
checkBoxName
- name of the checkbox.public boolean isCheckboxSelected(String checkBoxName, String checkBoxValue)
ITestingEngine
isCheckboxSelected
in interface ITestingEngine
checkBoxName
- name attribut of the checkbox.checkBoxValue
- value attribut of the checkbox.public boolean isTextInTable(String tableSummaryOrId, String text)
tableSummaryOrId
- table summary or id to inspect for expected text.text
- expected text to check for.public Table getTable(String tableSummaryNameOrId)
ITestingEngine
getTable
in interface ITestingEngine
tableSummaryNameOrId
- summary, name or id of the table to return.public boolean hasTable(String tableSummaryNameOrId)
ITestingEngine
hasTable
in interface ITestingEngine
tableSummaryNameOrId
- summary, name or id of the table.public void submit()
getForm()
for an explanation of how the
current form is established.submit
in interface ITestingEngine
public void submit(String buttonName)
getForm()
for an explanation of how the
current form is established.submit
in interface ITestingEngine
buttonName
- name of the button to use for submission.public void submit(String buttonName, String buttonValue)
getForm()
for an
explanation of how the current form is established.submit
in interface ITestingEngine
buttonName
- name of the button to use for submission.buttonValue
- value/label of the button to use for submissionpublic void reset()
getForm()
for an explanation of how the current form is established.reset
in interface ITestingEngine
public boolean hasLinkWithText(String linkText, int index)
hasLinkWithText
in interface ITestingEngine
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.public boolean hasLinkWithExactText(String linkText, int index)
ITestingEngine
hasLinkWithExactText
in interface ITestingEngine
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.public boolean hasLinkWithImage(String imageFileName, int index)
ITestingEngine
hasLinkWithImage
in interface ITestingEngine
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.public boolean hasLink(String anId)
hasLink
in interface ITestingEngine
anId
- link id to check for.public void clickLinkWithText(String linkText, int index)
ITestingEngine
clickLinkWithText
in interface ITestingEngine
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.public void clickLinkWithExactText(String linkText, int index)
ITestingEngine
clickLinkWithExactText
in interface ITestingEngine
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.public void checkCheckbox(String checkBoxName)
checkCheckbox
in interface ITestingEngine
checkBoxName
- name of checkbox to be deselected.public void checkCheckbox(String checkBoxName, String value)
ITestingEngine
checkCheckbox
in interface ITestingEngine
checkBoxName
- name of checkbox to be selected.value
- value of the checkbox (to differenciate checkboxes with the same name).public void uncheckCheckbox(String checkBoxName)
uncheckCheckbox
in interface ITestingEngine
checkBoxName
- name of checkbox to be deselected.public void uncheckCheckbox(String checkBoxName, String value)
ITestingEngine
uncheckCheckbox
in interface ITestingEngine
checkBoxName
- name of checkbox to be deselected.value
- value of the checkbox (to differenciate checkboxes with the same name).public void clickRadioOption(String radioGroup, String radioOption)
clickRadioOption
in interface ITestingEngine
radioGroup
- name of the radio group.radioOption
- value of the option to check for.public void clickLink(String anID)
clickLink
in interface ITestingEngine
anID
- id of link to be navigated.public void clickLinkWithImage(String imageFileName, int index)
clickLinkWithImage
in interface ITestingEngine
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.public boolean hasElement(String anID)
ITestingEngine
hasElement
in interface ITestingEngine
anID
- id of the element.public boolean hasElementByXPath(String xpath)
ITestingEngine
hasElementByXPath
in interface ITestingEngine
xpath
- xpath of the element.public void clickElementByXPath(String xpath)
ITestingEngine
clickElementByXPath
in interface ITestingEngine
xpath
- xpath of the element.public String getElementAttributByXPath(String xpath, String attribut)
ITestingEngine
getElementAttributByXPath
in interface ITestingEngine
xpath
- xpath of the element.attribut
- name of the attribut.public String getElementTextByXPath(String xpath)
ITestingEngine
getElementTextByXPath
in interface ITestingEngine
xpath
- xpath of the element.public void clickButton(String buttonId)
clickButton
in interface ITestingEngine
buttonId
- public void clickButtonWithText(String buttonValueText)
clickButtonWithText
in interface ITestingEngine
buttonValueText
- the text of the button (contents of the value attribute).public boolean hasRadioOption(String radioGroup, String radioOption)
hasRadioOption
in interface ITestingEngine
radioGroup
- name of the radio group.radioOption
- value of the option to check for.public String getSelectedRadio(String radioGroup)
ITestingEngine
getSelectedRadio
in interface ITestingEngine
radioGroup
- name of the radio group.public boolean hasSelectOption(String selectName, String optionLabel)
hasSelectOption
in interface ITestingEngine
selectName
- name of the select box.optionLabel
- label of the option.public boolean hasSelectOptionValue(String selectName, String optionValue)
hasSelectOptionValue
in interface ITestingEngine
selectName
- name of the select box.optionValue
- value of the option.public void selectOptions(String selectName, String[] options)
selectOptions
in interface ITestingEngine
selectName
- name of the select boxoptions
- set of options to select.public boolean hasSelectOption(String selectName, int index, String optionLabel)
hasSelectOption
in interface ITestingEngine
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.public boolean hasSelectOptionValue(String selectName, int index, String optionValue)
hasSelectOptionValue
in interface ITestingEngine
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.public void selectOptions(String selectName, int index, String[] options)
selectOptions
in interface ITestingEngine
selectName
- name of the select boxindex
- the 0-based index of the select element when multiple
select elements are expected.options
- set of options to select.public void unselectOptions(String selectName, String[] options)
ITestingEngine
unselectOptions
in interface ITestingEngine
selectName
- name of the select box.options
- vaules of the options to unselect.public void unselectOptions(String selectName, int index, String[] options)
ITestingEngine
unselectOptions
in interface ITestingEngine
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.public boolean isTextInElement(String elementID, String text)
ITestingEngine
isTextInElement
in interface ITestingEngine
elementID
- ID of element to inspect.text
- text to check for.public boolean isMatchInElement(String elementID, String regexp)
ITestingEngine
isMatchInElement
in interface ITestingEngine
elementID
- Id of element to inspect.regexp
- regexp to match.public void gotoRootWindow()
ITestingEngine.gotoFrame(String)
.gotoRootWindow
in interface ITestingEngine
protected TestContext getTestContext()
public void setExpectedJavaScriptAlert(JavascriptAlert[] alerts) throws ExpectedJavascriptAlertException
ITestingEngine
setExpectedJavaScriptAlert
in interface ITestingEngine
alerts
- Expected alerts.ExpectedJavascriptAlertException
- If there are still unconsummed alert since a previous call of this
method.public void setExpectedJavaScriptConfirm(JavascriptConfirm[] confirms) throws ExpectedJavascriptConfirmException
ITestingEngine
setExpectedJavaScriptConfirm
in interface ITestingEngine
confirms
- Expected confirms.ExpectedJavascriptConfirmException
- If there are still unconsummed confirm since a previous call of this
method.public void setExpectedJavaScriptPrompt(JavascriptPrompt[] prompts) throws ExpectedJavascriptPromptException
ITestingEngine
setExpectedJavaScriptPrompt
in interface ITestingEngine
prompts
- Expected prompts.ExpectedJavascriptPromptException
- If there are still unconsummed prompt since a previous call of this
method.public IElement getElementByXPath(String xpath)
ITestingEngine
getElementByXPath
in interface ITestingEngine
xpath
- XPath to evaluateITestingEngine.getElementsByXPath(String)
public IElement getElementByID(String id)
ITestingEngine
getElementByID
in interface ITestingEngine
id
- element ID to findpublic List<IElement> getElementsByXPath(String xpath)
ITestingEngine
getElementsByXPath
in interface ITestingEngine
xpath
- XPath to evaluateITestingEngine.getElementByXPath(String)
public int getServerResponseCode()
ITestingEngine
getServerResponseCode
in interface ITestingEngine
public WebResponse getWebResponse()
public void setIgnoreFailingStatusCodes(boolean ignore)
ITestingEngine
setIgnoreFailingStatusCodes
in interface ITestingEngine
public String getHeader(String name)
ITestingEngine
getHeader
in interface ITestingEngine
name
- The header name@Deprecated public Map<String,String> getAllHeaders()
ITestingEngine
getAllHeaders
in interface ITestingEngine
public List<HttpHeader> getResponseHeaders()
ITestingEngine
getResponseHeaders
in interface ITestingEngine
HttpHeader
spublic BrowserVersion getDefaultBrowserVersion()
user agent string manually
is to provide it with all the information for a complete browser version.BrowserVersion
public void setDefaultBrowserVersion(BrowserVersion defaultBrowserVersion)
user agent string manually
is to provide it with all the information for a complete browser version.the
- browser version to set as default for this engine instanceBrowserVersion
public void setTimeout(int milliseconds)
ITestingEngine
setTimeout
in interface ITestingEngine
milliseconds
- the milliseconds in which to timeout, or 0 for infinite
wait (the default).public void setRefreshHandler(RefreshHandler handler)
Copyright © 2002-2015 JWebUnit. All Rights Reserved.