|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jameleon.plugin.htmlunit.util.HtmlUnitHelper
public class HtmlUnitHelper
This class is used as a facade around the HtmlUnit API and is used by both the HtmlUnitSessionTag and the HtmlUnitFunctionTag.
Field Summary | |
---|---|
protected HtmlUnitDelegate |
delegate
|
Constructor Summary | |
---|---|
HtmlUnitHelper(HtmlUnitDelegate delegate)
|
Method Summary | |
---|---|
void |
clickElementWithXPath(String xpath)
Clicks on an HtmlElement (ClickableElement) defined by the provided XPath expression |
Page |
getCurrentPage()
Gets the current page in the currently active WebWindow |
String |
getCurrentPageContent()
Gets the HTML source from the currently active window |
WebResponse |
getCurrentWebResponse()
Gets the currnet WebResponse |
HtmlUnitDelegate |
getDelegate()
Gets the HtmlUnitDelegate that this object uses to communicate with the existing session. |
HtmlElement |
getHtmlElementByAttributeNameAndValue(String tagname,
String attributeName,
String attributeValue)
Gets an HTMLElement by the tag name, attribute name and the attribute value. |
HtmlElement |
getHtmlElementByXPath(DomNode container,
String xpath)
Gets an HtmlElement matching the provided xpath expression |
HtmlElement |
getHtmlElementByXPath(String xpath)
Gets an HtmlElement matching the provided xpath expression |
HtmlForm |
getHtmlFormById(String id)
Gets a form element back by its id attribute. |
HtmlForm |
getHtmlFormByIndex(int index)
Gets a form element back by its index or location on the page. |
HtmlForm |
getHtmlFormByName(String formName)
Gets a form element back by its name attribute. |
HtmlForm |
getHtmlFormByXPath(String xpath)
Gets a form element back by an XPath expression |
HtmlInput |
getHtmlInputByName(String fieldName)
Gets an HtmlInput tag based on the current workingForm or the currently active page if the workingForm is not set. |
HtmlInput |
getHtmlInputByNameAndValue(String fieldName,
String fieldValue)
Gets an HtmlInput tag based on the current workingForm or the currently active page if the workingForm is not set. |
void |
navigate(String url)
Navigates to the provided URL |
void |
setCheckBox(String fieldName,
boolean checked)
Checks or unchecks the checkbox that either exists in the workingForm or in the current page |
void |
setCheckBox(String fieldName,
String fieldValue,
boolean checked)
Checks or unchecks the checkbox that either exists in the workingForm or in the current page. |
void |
setFileField(String fieldName,
String value)
Sets the file field that either exists in the workingForm or in the current page |
void |
setHiddenField(String fieldName,
String value)
Sets the hidden field that either exists in the workingForm or in the current page |
void |
setHtmlInputValue(HtmlInput input,
String value,
String type)
Sets an input field type's value |
void |
setHtmlInputValueByXPath(String xpath,
String value,
String type)
Sets an input field type's value |
void |
setPasswordField(String fieldName,
String value)
Sets the password field that either exists in the workingForm or in the current page |
void |
setRadioButton(String fieldName,
String fieldValue,
boolean checked)
Checks or unchecks the radio button that either exists in the workingForm or in the current page. |
void |
setSelectFieldByIndex(String fieldName,
int index,
boolean selected)
Selects or unselects the option by its index order that either exists in the workingForm or in the current page. |
void |
setSelectFieldByOptionText(String fieldName,
String optionText,
boolean selected)
Selects or unselects the option with the displayed text that either exists in the workingForm or in the current page. |
void |
setSelectFieldByValue(String fieldName,
String valueAttribute,
boolean selected)
Selects or unselects the option with the given attribute value that either exists in the workingForm or in the current page. |
void |
setSelectFieldByXPath(String xpath,
boolean selected)
Selects or unselects the option defined by XPath. |
void |
setTextArea(String fieldName,
String value)
Sets the text area that either exists in the workingForm or in the current page |
void |
setTextField(String fieldName,
String value)
Sets the text field that either exists in the workingForm or in the current page |
File |
store(String fName)
Store the contents of the currently active window |
boolean |
xPathMatches(String xpath)
Checks that the the provided XPath expression matches something on the current page. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected HtmlUnitDelegate delegate
Constructor Detail |
---|
public HtmlUnitHelper(HtmlUnitDelegate delegate)
Method Detail |
---|
public void clickElementWithXPath(String xpath)
xpath
- - The XPath expression to locate the element to click on.public HtmlUnitDelegate getDelegate()
public Page getCurrentPage()
public String getCurrentPageContent()
public WebResponse getCurrentWebResponse()
public HtmlElement getHtmlElementByXPath(String xpath)
xpath
- - An XPath expression that matches the desired HtmlElement
public HtmlElement getHtmlElementByXPath(DomNode container, String xpath)
container
- - The DOM to start atxpath
- - An XPath expression that matches the desired HtmlElement
public HtmlElement getHtmlElementByAttributeNameAndValue(String tagname, String attributeName, String attributeValue)
tagname
- - The name of the tag to get back. In the above example, the value would be 'form'attributeName
- - The name of attribute to check against. In the above example, the value would be 'id'attributeValue
- - The value of the attribute to check against. In the above example, the value would be 'ten'
public HtmlForm getHtmlFormById(String id)
id
- - the value of the id attribute.
public HtmlForm getHtmlFormByIndex(int index)
index
- - the nth form on the page
public HtmlForm getHtmlFormByName(String formName)
formName
- - the value of the name attribute.
public HtmlForm getHtmlFormByXPath(String xpath)
xpath
- - The XPath expression matching the desired form
public HtmlInput getHtmlInputByName(String fieldName)
fieldName
- - The name of the input field
public HtmlInput getHtmlInputByNameAndValue(String fieldName, String fieldValue)
fieldName
- - The name of the input fieldfieldValue
- - The value of the input field
public void navigate(String url)
url
- - the url to navigate to.public void setCheckBox(String fieldName, boolean checked)
fieldName
- - The name of the input field to set the value ofchecked
- - set to true
to check the checkbox and to false
to uncheck itpublic void setCheckBox(String fieldName, String fieldValue, boolean checked)
fieldName
- - The name of the checkbox to checkfieldValue
- - The value of the input field to checkchecked
- - set to true
to check the checkbox and to false
to uncheck itpublic void setFileField(String fieldName, String value)
fieldName
- - The name of the input field to set the value ofvalue
- - The value to set the input field topublic void setHiddenField(String fieldName, String value)
fieldName
- - The name of the input field to set the value ofvalue
- - The value to set the input field topublic void setPasswordField(String fieldName, String value)
fieldName
- - The name of the input field to set the value ofvalue
- - The value to set the input field topublic void setRadioButton(String fieldName, String fieldValue, boolean checked)
fieldName
- - The name of the radio button to checkfieldValue
- - The value of the radio button to checkchecked
- - set to true
to check the radio button and to false
to uncheck itpublic void setSelectFieldByIndex(String fieldName, int index, boolean selected)
fieldName
- - The name of the select field to selectindex
- - The nth option in the list. 1st option = 1selected
- - set to true
to select and to false
to unselect itpublic void setSelectFieldByOptionText(String fieldName, String optionText, boolean selected)
fieldName
- - The name of the select field to selectoptionText
- - The text displayed in the drop-downselected
- - set to true
to select and to false
to unselect itpublic void setSelectFieldByValue(String fieldName, String valueAttribute, boolean selected)
fieldName
- - The name of the select field to selectvalueAttribute
- - The value of option field to selectselected
- - set to true
to select and to false
to unselect itpublic void setSelectFieldByXPath(String xpath, boolean selected)
xpath
- - The XPath expression that matches an HtmlOption (not a select) to be selectedselected
- - set to true
to select and to false
to unselect itpublic void setTextArea(String fieldName, String value)
fieldName
- - The name of the input field to set the value ofvalue
- - The value to set the input field topublic void setTextField(String fieldName, String value)
fieldName
- - The name of the input field to set the value ofvalue
- - The value to set the input field topublic void setHtmlInputValue(HtmlInput input, String value, String type)
input
- - The HtmlInput to set the value onvalue
- - The value to set the input element to.type
- - The input type. If this does not match the given field, then this method will failpublic void setHtmlInputValueByXPath(String xpath, String value, String type)
xpath
- - An XPath expression that matches the desired HtmlInput Element.value
- - The value to set the input element to.type
- - The input type. If this does not match the given field, then this method will failpublic File store(String fName) throws IOException
fName
- - The name of the file to store the source to.
IOException
public boolean xPathMatches(String xpath)
xpath
- - The XPath expression to evaulate
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |