Manual

45.1.1
The abstract Node class

All classes of QF-Test's pseudo DOM are derived from this class and thus implement the following interface. Its is located in the package de.qfs.apps.qftest.client.web.dom.

 
 
String getNodeType()
Get an identifier for the type of the node. Though this method is not fully in line with pure OO doctrine, while traversing the DOM it is often necessary to find out the type of a given node and this is quite convenient.
Returns A string specifying the type of node. The respective constants are defined in the concrete sub-classes: DocumentNode.DOCUMENT_NODE, FrameNode.FRAME_NODE, DomNode.DOM_NODE and DialogNode.DIALOG_NODE.
 
String getName()
Get the tag name of the node. The tag name is the type of node in upper case like "HTML" for an <HTML> node. Plain text nodes are represented as a DomNode with tag name "#text". Pseudo tag names are defined for DocumentNodes ("DOCUMENT") and DialogNodes ("DIALOG").
ReturnsThe tag name of the node.
 
String getAttribute(String name)
Get the value of an attribute of the node. For convenience this method is defined at Node level. If this node is not a DomNode the result will always be null. In some cases this method also returns attributes that have not been explicitly specified, like the width and height of an <IMG> node. Which attributes can be retrieved in that way is browser dependent.
Parameters
nameThe name of the attribute
Returns The value of the attribute or null if no such attribute is available for the node.
 
String getAttributeIfSpecified(String name)
Get the value of an attribute of the node if it is explicitly specified in the HTML code. For convenience this method is defined at Node level. If this node is not a DomNode the result will always be null.
Parameters
nameThe name of the attribute
Returns The value of the attribute or null if no such attribute is explicitly specified for the node.
 
boolean isAttributeSpecified(String name)
Test whether an attribute of the node is explicitly specified in the HTML code. For convenience this method is defined at Node level. If this node is not a DomNode the result will always be false.
Parameters
nameThe name of the attribute
Returns True if an attribute is explicitly specified for the node.
 
String getText()
Get the text content of a Node. In case of a plain text node, return its value. Otherwise traverse the DOM and collect all nested text node's values. Care is taken to collapse whitespace between nodes to get as close as possible to what is displayed in the browser.
Returns The whole direct and indirect text content of a node.
 
String getVisibleText()
Get the text content of a Node. In case of a plain text node, return its value. Otherwise traverse the DOM and collect all nested text node's values, ignoring invisible nodes. Care is taken to collapse whitespace between nodes to get as close as possible to what is displayed in the browser.
Returns The whole direct and indirect visible text content of a node.
 
String getFlatText()
Get the flat text content of a Node. In case of a plain text node, return its value. Otherwise collect the values of all text nodes directly contained within this node, excluding those nested at a deeper level.
Returns The whole direct text content of a node.
 
String getVisibleFlatText()
Get the flat text content of a Node. In case of a plain text node, return its value. Otherwise collect the values of all text nodes directly contained within this node, excluding invisible ones and those nested at a deeper level.
Returns The whole direct visible text content of a node.
 
String getSimpleText()
Get the simple text content of a Node. In case of a plain text node, return its value. Otherwise traverse the DOM and collect all text nodes contained directly within this node or in "simple" nodes like <B>, but do not descend into structurally more complex nodes like <TABLE>.
ReturnsThe simple text content of a node.
 
String getVisibleSimpleText()
Get the simple text content of a Node. In case of a plain text node, return its value. Otherwise traverse the DOM and collect all visible text nodes contained directly within this node or in "simple" nodes like <B>, but do not descend into structurally more complex nodes like <TABLE>.
ReturnsThe visible simple text content of a node.
 
DocumentNode getDocument()
Get the document to which this node belongs.
Returns The document to which this node belongs. A DocumentNode will return itself, a DialogNode will return null.
 
Browser isBrowserIE()
Test whether the browser to which the node belongs is an Internet Explorer.
ReturnsTrue for Internet Explorer, false for Mozilla derivatives.
 
Browser isBrowserMozilla()
Test whether the browser to which the node belongs is a Mozilla derivative.
ReturnsTrue for Mozilla derivatives, false for Internet Explorer.
 
Node getParent()
Get the parent of a node. A top-level DocumentNode or a DialogNode will return null. Everything else should have a parent unless removed from the DOM via JavaScript.
ReturnsThe parent of the node.
 
int getChildCount()
Get the number of child nodes.
ReturnsThe number of child nodes.
 
Node getChild(int index)
Get the child node at the given index.
Parameters
indexThe index of the child node, starting with 0.
ReturnsThe child node at the index.
Throws
IllegalArgumentException If index is negative or exceeds the number of child nodes.
 
Node[] getChildren()
Get the children of this node as an array.
ReturnsThe child nodes.
 
int getIndexOfChild(Node child)
Get the index of a given child node.
Parameters
childThe child node to get the index for.
Returns The index of the child node, starting with 0, or -1 in case it is not a child of the this node.
 
Node[] getElementsByTagName(String tagName)
Get all direct or indirect child nodes of this node with a given tag name.
Parameters
tagNameThe tag name to look for.
Returns An array of child nodes with the given tag name. If none are found, an empty array is returned. A DialogNode will always return an empty array, a FrameNode forwards the call to its DocumentNode child node and a DocumentNode to its <HTML> root element.
 
Node getElementById(String id)
Get a direct or indirect child node of this node with a given ID. The given ID is not compared to the node's original 'ID' attribute, but to its ID, which may have been modified by an IdResolver (see subsection 46.1.16).
Parameters
idThe ID to look for.
Returns The child node with the given ID, an arbitrary one in case of multiple matches or null if none is found. A DialogNode will always return null, a FrameNode forwards the call to its DocumentNode child node and a DocumentNode to its <HTML> root element.
 
Node[] getElementsById(String id)
Get all direct or indirect child nodes of this node with a given ID. The given ID is not compared to the node's original 'ID' attribute, but to its ID, which may have been modified by an IdResolver (see subsection 46.1.16).
Parameters
idThe ID to look for.
Returns An array of child nodes with the given ID. If none are found, an empty array is returned. A DialogNode will always return an empty array, a FrameNode forwards the call to its DocumentNode child node and a DocumentNode to its <HTML> root element.
 
Node[] getElementsByIdAndTagname(String id, String tagName)
Get all direct or indirect child nodes of this node with a given ID and a given tag name. The given ID is not compared to the node's original 'ID' attribute, but to its ID, which may have been modified by an IdResolver (see subsection 46.1.16).
Parameters
idThe ID to look for.
tagNameThe tag name to look for.
Returns An array of child nodes with the given ID and the given tag name. If none are found, an empty array is returned. A DialogNode will always return an empty array, a FrameNode forwards the call to its DocumentNode child node and a DocumentNode to its <HTML> root element.
 
Object getProperty(String name)
Retrieve a user-defined property.
Parameters
nameThe name of the property to retrieve.
ReturnsThe value of the specified property or null.
 
setProperty(String name, Object value)
Set a user-defined property.
Parameters
nameThe name of the property.
value The property value or null to remove an existing property.
 
Node getInterestingParent()
Get the interesting parent of a node. A top-level DocumentNode or a DialogNode will return null. Everything else should have a parent unless removed from the DOM via JavaScript.
ReturnsThe interesting parent of the node.
 
Node getInterestingParent(int n)
Get the interesting parent of a node. A top-level DocumentNode or a DialogNode will return null. Everything else should have a parent unless removed from the DOM via JavaScript.
Parameters
nThe interesting parent's level.
ReturnsThe interesting parent of the node.
 
Node getNthParent(int n)
Get the n-th parent node.
Parameters
nThe parent's level.
ReturnsThe n-th parent or null.
 
Node getAncestorOfClass(String clazz)
Get the closest parent of a specified class name.
Parameters
clazzThe parent's class name.
ReturnsThe parent or null.
 
Node getAncestorOfClass(String clazz, int maxDepth)
Get the closest parent of a specified class name. You can specify a maximal search level.
Parameters
clazzThe parent's class name.
maxDepthThe maximum search level.
ReturnsThe parent or null.
 
Node findCommonAncestor(Node node1, Node node2, Node topmost)
Get the common parent of two nodes.
Parameters
node1The first node.
node2The second node.
topmostThe topmost node to stop the search.
ReturnsThe common parent or null.
 
boolean isAncestor(Node node)
Check whether the given node is an ancestor of the current node.
Parameters
nodeThe possible ancestor node.
ReturnsTrue, if node is an ancestor, otherwise false.
 
Node[] getElementsByClassName(String className)
Get all direct and indirect child nodes with a specified class.
Parameters
classNameThe name of the class.
ReturnsAn array of child nodes with the specified class name. If none are found, an empty array is returned.
 
String[] getClassNames()
Get all class names of that node.
ReturnsAn array with all class names of that node.
 
String getClassName()
Get the most current class name of that node.
ReturnsThe most current class name.
 
String getGenericClassName()
Get the generic class name of that node.
ReturnsThe generic class name.
 
boolean isMatchingClass(String className)
Check, whether the node matches a given class name.
Parameters
classNameThe class name to check.
ReturnsTrue, if node matches this class, otherwise false.