|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jameleon.plugin.jiffie.util.IHTMLElementFinder
public class IHTMLElementFinder
This class was created to be used by the IEFunctionTag. The idea is to have the logic in this class and simply have have the IEFunctionTag be a facade. This should make unit testing much easier and the IEFunctionTag much smaller.
Field Summary | |
---|---|
protected DocumentDelegate |
docDelegate
|
Constructor Summary | |
---|---|
IHTMLElementFinder(DocumentDelegate docDelegate)
|
Method Summary | |
---|---|
protected boolean |
attributeValueMatches(String attributeName,
String expectedValue,
String actualValue)
|
IHTMLElement |
getAreaElementByAltText(String altText)
Gets the area HTML tag with the given alt text |
String |
getAttributeValue(IHTMLElement element,
String attributeName)
Gets an attribute's value for a given element |
IHTMLDOMNode |
getByXPath(String xpath2evaluate)
This method returns the IHTMLDOMNode identified by the given xpath. |
IHTMLInputElement |
getCheckbox(String checkboxFieldName)
Gets the checkbox given by it's field name |
IHTMLInputElement |
getCheckboxWithNameAndValue(String checkboxFieldName,
String checkboxFieldValue)
Gets the checkbox given by it's field name and value |
IHTMLElement |
getElementByXPath(String xpath2evaluate)
|
List |
getElementsByXPath(String xpath2evaluate)
|
IHTMLInputElement |
getFileInputField(String fieldName)
Gets the file input field given by it's field name |
IHTMLFormElement |
getForm(String formInfo)
Tries to get a form via the following methods in order. |
IHTMLElement |
getFormElement(String htmlTag,
String[] attributeNames,
String[] attributeValues)
Gets the first matching element with given attributes and attribute values |
IHTMLElement |
getFormElement(String htmlTag,
String attributeName,
String attributeValue)
Gets the first matching element with a given attribute and attribute value |
List |
getFormElements(String htmlTag)
Gets a list of html elements. |
List |
getFormElements(String htmlTag,
String[] attributeNames,
String[] attributeValues)
Gets a list of elements with given attributes and attribute values |
List |
getFormElements(String htmlTag,
String attributeName,
String attributeValue)
Gets a list of elements with a given attribute and attribute value |
ElementList |
getForms()
|
IHTMLFormElement |
getFormWithId(String id)
Tries to get a form with the id attribute provided |
IHTMLFormElement |
getFormWithIndex(int index)
Tries to get the nth form on the page. |
IHTMLFormElement |
getFormWithName(String name)
Tries to get a form with the name attribute provided |
IHTMLFormElement |
getFormWithXPath(String xpath)
Gets a form with the given XPATH. |
IHTMLFrameBase2 |
getFrame(ElementContainer container,
String attrName,
String attrValue)
Gets a frame by the name attribute |
IHTMLFrameBase2 |
getFrameWithId(ElementContainer container,
String frameId)
Gets a frame by the id attribute |
IHTMLFrameBase2 |
getFrameWithId(String frameId)
Gets a frame by the id attribute |
IHTMLFrameBase2 |
getFrameWithName(ElementContainer container,
String frameName)
Gets a frame by the name attribute |
IHTMLFrameBase2 |
getFrameWithName(String frameName)
Gets a frame by the name attribute |
IHTMLFrameBase2 |
getFrameWithSrc(ElementContainer container,
String frameSrc)
Gets a frame by the src attribute |
IHTMLFrameBase2 |
getFrameWithSrc(String frameSrc)
Gets a frame by the src attribute |
IHTMLInputElement |
getHiddenField(String fieldName)
Gets the hidden field given by it's field name |
IHTMLElement |
getIHTMLElement(ElementContainer container,
String htmlTag,
String[] attributeNames,
String[] attributeValues)
Gets the first matching IHTMLElement with the given html tag, attributes and attribute values |
IHTMLElement |
getIHTMLElement(ElementContainer container,
String htmlTag,
String attributeName,
String attributeValue)
Gets the first matching IHTMLElement with the given html tag, attribute and attribute value |
IHTMLElement |
getIHTMLElement(String htmlTag,
String[] attributeNames,
String[] attributeValues)
Gets the first matching IHTMLElement with the given html tag, attributes and attribute values |
IHTMLElement |
getIHTMLElement(String htmlTag,
String attributeName,
String attributeValue)
Gets the first matching IHTMLElement with the given html tag, attribute and attribute value |
List |
getIHTMLElements(ElementContainer container,
String htmlTag,
String[] attributeNames,
String[] attributeValues)
Gets a List of matching IHTMLElements with the given html tag, attributes and attribute values |
List |
getIHTMLElements(ElementContainer container,
String htmlTag,
String attributeName,
String attributeValue)
Gets a List of matching IHTMLElements with the given html tag, attribute and attribute value |
List |
getIHTMLElements(String htmlTag,
String[] attributeNames,
String[] attributeValues)
Gets a List of matching IHTMLElements with the given html tag, attributes and attribute values |
List |
getIHTMLElements(String htmlTag,
String attributeName,
String attributeValue)
Gets a List of matching IHTMLElements with the given html tag, attribute and attribute value |
IHTMLAnchorElement |
getImageLinkWithAltText(String text)
Helper method to find a link with given img alt text |
IHTMLInputElement |
getInputFieldByName(String inputFieldName)
Tries to get an input field by name. |
List |
getInputFieldsByName(String inputFieldName)
Tries to get an input field by name. |
IHTMLAnchorElement |
getLink(String text)
Tries to get a link via the following methods in order. |
List |
getLinksWith(String text)
Helper method to find all links with contained text |
IHTMLAnchorElement |
getLinkWith(String text)
Helper method to find a link with contained text |
IHTMLAnchorElement |
getLinkWithHref(String regex,
String text)
Helper method to find a link with the regex found in the href, and the text contained in the inner text, ID, or name. |
IHTMLAnchorElement |
getLinkWithID(String id)
Helper method to find a link with given id |
IHTMLAnchorElement |
getLinkWithImageSrc(String src)
Helper method to find a link with given img src attribute |
IHTMLAnchorElement |
getLinkWithName(String name)
Helper method to find a link with given name |
IHTMLInputElement |
getPasswordField(String passwordFieldName)
Gets the text field given by it's field name |
IHTMLInputElement |
getRadioButton(String radioButtonName,
String value)
Gets the radio button with the specified name and value |
IHTMLOptionElement |
getSelectedOptionField(String selectFieldName)
Gets the currently selected option from the given select field defined by selectFieldName |
IHTMLSelectElement |
getSelectField(String selectFieldName)
Gets the select field defined by selectFieldName |
IHTMLOptionElement |
getSelectOptionWithText(String selectFieldName,
String displayedText)
Gets the currently selected option from the given select field defined by selectFieldName |
IHTMLInputElement |
getSubmit(String id)
Tries to get a submit element in the following order. |
IHTMLInputElement |
getSubmit(String type,
String value)
Gets the submit button identified by it's value (the label shown in the browser). |
IHTMLInputElement |
getSubmitButtonWithName(String buttonName)
Gets a submit button by it's name from the working form |
IHTMLInputElement |
getSubmitButtonWithNameAndValue(String buttonName,
String value)
Gets the first submit button by it's name from the working form |
IHTMLInputElement |
getSubmitButtonWithValue(String value)
Gets the first submit button by it's value from the working form |
IHTMLTextAreaElement |
getTextArea(String fieldName)
Gets the text area given by it's field name |
IHTMLInputElement |
getTextField(String fieldName)
Gets the text field given by it's field name |
void |
highlightElement(IHTMLElement element)
|
void |
highlightFormField(IHTMLElement element)
|
protected IHTMLFrameBase2 |
internalGetFrame(ElementContainer container,
String attrName,
String attrValue)
Gets a frame by the specified attribute |
boolean |
isTextInPage(String text)
Checks to see if the current page has the desired block of text |
List |
parseStringOfTokens(String tokenSeparatedList,
String token)
Parses a comma-separated list. |
protected void |
release(IDispatch dis)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DocumentDelegate docDelegate
Constructor Detail |
---|
public IHTMLElementFinder(DocumentDelegate docDelegate)
Method Detail |
---|
public IHTMLElement getAreaElementByAltText(String altText)
altText
- - the alt text that the desired area tag should have
public String getAttributeValue(IHTMLElement element, String attributeName)
element
- - The element that contains the attributeattributeName
- - The name of the attribute with the desired value
public IHTMLDOMNode getByXPath(String xpath2evaluate)
xpath2evaluate
- - The xpath identifying the wanted node in the DOM.
public IHTMLInputElement getCheckbox(String checkboxFieldName)
checkboxFieldName
- - the name of the checkbox
RuntimeException
- if the field does not exist in the form.public IHTMLInputElement getCheckboxWithNameAndValue(String checkboxFieldName, String checkboxFieldValue)
checkboxFieldName
- - the name of the checkboxcheckboxFieldValue
- - the value of the checkbox
RuntimeException
- if the field does not exist in the form.public IHTMLElement getElementByXPath(String xpath2evaluate)
xpath2evaluate
- - The XPath identifying the element
public List getElementsByXPath(String xpath2evaluate)
xpath2evaluate
- - The XPath identifying the element
public IHTMLFrameBase2 getFrameWithId(ElementContainer container, String frameId)
container
- - the ElementContainer that contains the desired frame.frameId
- - the id of the frame
public IHTMLFrameBase2 getFrameWithId(String frameId)
frameId
- - the id of the frame
public IHTMLFrameBase2 getFrameWithName(ElementContainer container, String frameName)
container
- - the ElementContainer that contains the desired frame.frameName
- - the name of the frame
public IHTMLFrameBase2 getFrameWithName(String frameName)
frameName
- - the name of the frame
public IHTMLFrameBase2 getFrameWithSrc(ElementContainer container, String frameSrc)
container
- - the ElementContainer that contains the desired frame.frameSrc
- - the source of the frame
public IHTMLFrameBase2 getFrameWithSrc(String frameSrc)
frameSrc
- - the source of the frame
public IHTMLFrameBase2 getFrame(ElementContainer container, String attrName, String attrValue)
container
- - the ElementContainer that contains the desired frame.attrName
- - the attribute with which to find the frame(name/id/src)attrValue
- - the name,id, or src of the frame. This can be a comma-separated
list of names, ids or srcs.
protected IHTMLFrameBase2 internalGetFrame(ElementContainer container, String attrName, String attrValue)
container
- - the ElementContainer that contains the desired frame.attrName
- - the attribute with which to find the frame (name, id, src)attrValue
- - the name,id, or src of the frame
public List parseStringOfTokens(String tokenSeparatedList, String token)
tokenSeparatedList
- - A token-delimited Stringtoken
- - The token to parse the String with
public IHTMLFormElement getForm(String formInfo)
getFormWithId()
- Gets a form with the expected id attribute
getFormWithName()
- Gets a form with the expected name attribute
getFormWithIndex()
- The parameter is converted to a number, representing
the index of the form on the page.
getFormWithXPath
- Gets a form with the expected XPath
formInfo
- - The form id or name or index or XPath identifying the form
null
if no Form
is found.public IHTMLElement getFormElement(String htmlTag, String attributeName, String attributeValue)
htmlTag
- - The name of the element or tag. For an input element, you'd pass "input"attributeName
- - The name of the attribute to exist in the element.attributeValue
- - The value of the name attribute to exist in the element.public IHTMLElement getFormElement(String htmlTag, String[] attributeNames, String[] attributeValues)
htmlTag
- - The name of the element or tag. For an input
element, you'd pass "input"attributeNames
- - A List of names of attributes to
exist in the element.attributeValues
- - A List of values of name attributes
to exist in the element. Must be in
the same order as attributeNamespublic List getFormElements(String htmlTag)
htmlTag
- - The name of the element or tag. For an input element, you'd pass "input"public List getFormElements(String htmlTag, String attributeName, String attributeValue)
htmlTag
- - The name of the element or tag. For an input element, you'd pass "input"attributeName
- - The name of the attribute to exist in the element.attributeValue
- - The value of the name attribute to exist in the element.public List getFormElements(String htmlTag, String[] attributeNames, String[] attributeValues)
htmlTag
- - The name of the element or tag. For an input
element, you'd pass "input"attributeNames
- - A List of names of attributes to
exist in the element.attributeValues
- - A List of values of name attributes
to exist in the element. Must be in
the same order as attributeNamespublic ElementList getForms()
public IHTMLFormElement getFormWithId(String id)
id
- - The name of the form to be returned.
public IHTMLFormElement getFormWithIndex(int index)
index
- - The number representing the (n-1)th form. The first form would be 0
public IHTMLFormElement getFormWithName(String name)
name
- - The name of the form to be returned.
public IHTMLFormElement getFormWithXPath(String xpath)
xpath
- - the XPATH of the form
public IHTMLInputElement getHiddenField(String fieldName)
fieldName
- - the name of the hidden field
RuntimeException
- if the field does not exist in the form.public IHTMLElement getIHTMLElement(ElementContainer container, String htmlTag, String attributeName, String attributeValue)
container
- - The ElementContainer to use to get the attributes out of.htmlTag
- - The HTML tag to get back.attributeName
- - the attibute in the HTML elementattributeValue
- - the value of attibute in the HTML element
public IHTMLElement getIHTMLElement(String htmlTag, String attributeName, String attributeValue)
htmlTag
- - The HTML tag to get back.attributeName
- - the attibute in the HTML elementattributeValue
- - the value of attibute in the HTML element
public IHTMLElement getIHTMLElement(ElementContainer container, String htmlTag, String[] attributeNames, String[] attributeValues)
container
- - The ElementContainer to use to get the attributes out of.htmlTag
- - The HTML tag to get back.attributeNames
- - a list of attibutes in the HTML elementattributeValues
- - a list of values of attibutes in the same order as the names
public IHTMLElement getIHTMLElement(String htmlTag, String[] attributeNames, String[] attributeValues)
htmlTag
- - The HTML tag to get back.attributeNames
- - a list of attibutes in the HTML elementattributeValues
- - a list of values of attibutes in the same order as the names
public List getIHTMLElements(ElementContainer container, String htmlTag, String attributeName, String attributeValue)
container
- - The ElementContainer to use to get the attributes out of.htmlTag
- - The HTML tag to get back.attributeName
- - the attibute in the HTML elementattributeValue
- - the value of attibute in the HTML element
public List getIHTMLElements(String htmlTag, String attributeName, String attributeValue)
htmlTag
- - The HTML tag to get back.attributeName
- - the attibute in the HTML elementattributeValue
- - the value of attibute in the HTML element
public List getIHTMLElements(ElementContainer container, String htmlTag, String[] attributeNames, String[] attributeValues)
container
- - The ElementContainer to use to get the attributes out of.htmlTag
- - The HTML tag to get back.attributeNames
- - a list of attibutes in the HTML elementattributeValues
- - a list of values of attibutes in the same order as the names
public List getIHTMLElements(String htmlTag, String[] attributeNames, String[] attributeValues)
htmlTag
- - The HTML tag to get back.attributeNames
- - a list of attibutes in the HTML elementattributeValues
- - a list of values of attibutes in the same order as the names
public IHTMLAnchorElement getImageLinkWithAltText(String text)
text
- - The alt text of the img contained by the link
public IHTMLInputElement getInputFieldByName(String inputFieldName)
inputFieldName
- - The name of the input field that exists in the current working form
public List getInputFieldsByName(String inputFieldName)
inputFieldName
- - The name of the input field that exists in the current working form
public IHTMLAnchorElement getLink(String text)
getLinkWith()
- Gets a link with the diplayed text
getLinkWithID()
- Gets a link with the id
attribute set.
getImageLinkWithAltText
- Gets a link with the alt attribute or alt text.
getLinkWithName()
- Gets a link with the name attribute set.
getLinkWithImageSrc()
- Gets a link with the image src.
text
- - The link text or the link id or the alt text or the link name.
null
if no WebLink
is found.
todo order should be id, name, label, imageText.public IHTMLAnchorElement getLinkWith(String text)
text
- - The text contained by the link
public IHTMLAnchorElement getLinkWithHref(String regex, String text)
regex
- - The regex to be found in the href attribute of the linktext
- - The text contained by the link
public List getLinksWith(String text)
text
- - The text contained by the links
public IHTMLAnchorElement getLinkWithID(String id)
id
- - The id of the link
public IHTMLAnchorElement getLinkWithImageSrc(String src)
src
- - The part of the src attribute of the img contained by the link
public IHTMLAnchorElement getLinkWithName(String name)
name
- - The name of the link to find
public IHTMLInputElement getPasswordField(String passwordFieldName)
passwordFieldName
- - the name of the password field
RuntimeException
- if the field does not exist in the form.public IHTMLInputElement getRadioButton(String radioButtonName, String value)
radioButtonName
- - the name of the radio buttonvalue
- - the value to set the radio button to.
public IHTMLSelectElement getSelectField(String selectFieldName)
selectFieldName
selectFieldName
- - the name of the select field
selectFieldName
.public IHTMLOptionElement getSelectedOptionField(String selectFieldName)
selectFieldName
selectFieldName
- - the name of the select field
public IHTMLOptionElement getSelectOptionWithText(String selectFieldName, String displayedText)
selectFieldName
selectFieldName
- - the name of the select fielddisplayedText
- - the text displayed in the browser
public IHTMLInputElement getSubmit(String id)
id
- - The identifier of the submit element to find.
For submit and button types, it will try to match it with the value attribute.
For image input types, it will try to match it with the src or alt attribute.
public IHTMLInputElement getSubmit(String type, String value)
type
- - type of submit field 'submit', 'image' or 'button'value
- - the value of the submit field (this is the label of the submit button shown in the browser)
RuntimeException
- if the field does not exist in the form.
todo introduce constants for supported types.public IHTMLInputElement getSubmitButtonWithName(String buttonName)
buttonName
- - the name of the submit button
buttonName
RuntimeException
- if the desired submit button isn't found in the working form.public IHTMLInputElement getSubmitButtonWithNameAndValue(String buttonName, String value)
buttonName
- - the name of the submit buttonvalue
- - the value attribute of the button
buttonName
and value
.
RuntimeException
- if the desired submit button isn't found in the working form.public IHTMLInputElement getSubmitButtonWithValue(String value)
value
- - the value attribute of the button
value
.
RuntimeException
- if the desired submit button isn't found in
the working form.public IHTMLInputElement getTextField(String fieldName)
fieldName
- - the name of the text field
RuntimeException
- if the field does not exist in the form.public IHTMLInputElement getFileInputField(String fieldName)
fieldName
- - the name of the file input field
RuntimeException
- if the field does not exist in the form.public IHTMLTextAreaElement getTextArea(String fieldName)
fieldName
- - the name of the text area
RuntimeException
- if the field does not exist in the form.public boolean isTextInPage(String text)
text
- - the expected text
protected void release(IDispatch dis)
public void highlightElement(IHTMLElement element)
public void highlightFormField(IHTMLElement element)
protected boolean attributeValueMatches(String attributeName, String expectedValue, String actualValue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |