net.sourceforge.jwebunit.api
Interface IElement

All Known Implementing Classes:
HtmlUnitElementImpl

public interface IElement

A wrapper around elements so we can access their properties directly, without requiring either direct access to the testing engine DOM, or implementing every permutation of assert test.

Author:
jmwright

Method Summary
 boolean equals(java.lang.Object obj)
          Two IElements are equal if they refer to the same element in the current page.
 java.lang.String getAttribute(java.lang.String name)
          Get the value of an attribute.
 java.util.List<IElement> getChildren()
          Get direct child elements of this element.
 IElement getElement(java.lang.String xpath)
          Get an element from this element by xpath.
 java.util.List<IElement> getElements(java.lang.String xpath)
          Get all elements from this element by xpath.
 java.lang.String getName()
          Get the element name, for example "input", "textarea", "select".
 IElement getParent()
          Get the parent element, or null if none exists.
 java.lang.String getTextContent()
          Get the text content, if any, of this element.
 void setAttribute(java.lang.String string)
          Set an attribute on this element.
 void setAttribute(java.lang.String string, java.lang.String value)
          Set an attribute on this element.
 void setTextContent(java.lang.String value)
          Set the text content on this element.
 

Method Detail

getAttribute

java.lang.String getAttribute(java.lang.String name)
Get the value of an attribute.

Parameters:
name - The attribute name
Returns:
The value of the attribute

getName

java.lang.String getName()
Get the element name, for example "input", "textarea", "select".

Returns:
The element name

getTextContent

java.lang.String getTextContent()
Get the text content, if any, of this element.

Returns:
The text content, if any, of this element.

getParent

IElement getParent()
Get the parent element, or null if none exists.

Returns:
The parent element or null

getChildren

java.util.List<IElement> getChildren()
Get direct child elements of this element.

Returns:
A list of child elements

getElement

IElement getElement(java.lang.String xpath)
Get an element from this element by xpath.

Parameters:
xpath - The xpath to serach
Returns:
an IElement if found, or null

getElements

java.util.List<IElement> getElements(java.lang.String xpath)
Get all elements from this element by xpath.

Parameters:
xpath - The xpath to search
Returns:
A list of all matching elements

setAttribute

void setAttribute(java.lang.String string)
Set an attribute on this element.

Parameters:
string -

setAttribute

void setAttribute(java.lang.String string,
                  java.lang.String value)
Set an attribute on this element.

Parameters:
string -
value -

setTextContent

void setTextContent(java.lang.String value)
Set the text content on this element.

Parameters:
value -

equals

boolean equals(java.lang.Object obj)
Two IElements are equal if they refer to the same element in the current page.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare
Returns:
true if the object is an IElement, and refers to the same element as this IElement


Copyright © 2002-2011 SourceForge. All Rights Reserved.