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.

 
 
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.
 
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.
 
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.
 
Node getChild(int index)
Get the child node at the given index. Remark for Opera before version 86, Google Chrome and Microsoft Edge before version 100: Text-nodes, which are only used to format the HTML code and which have no influence on the visualisation of the web site are not transferred from the browser to QF-Test in CDP connection mode. Therefore, a different index of the child node can occure in this connection mode wth these browsers. If possible, use getChildrenByTagName in your scripts.
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.
 
int getChildCount()
Get the number of child nodes. Remark for Opera before version 86, Google Chrome and Microsoft Edge before version 100: Text-nodes, which are only used to format the HTML code and which have no influence on the visualisation of the web site are not transferred from the browser to QF-Test in CDP connection mode. Therefore, a different number of the child nodes can occure in this connection mode with these browsers.
ReturnsThe number of child nodes.
 
Node[] getChildren()
Get the children of this node as an array. Remark for Opera before version 86, Google Chrome and Microsoft Edge before version 100: Text-nodes, which are only used to format the HTML code and which have no influence on the visualisation of the web site are not transferred from the browser to QF-Test in CDP connection mode. Therefore, less children might be reported in this connection mode with these browsers.
ReturnsThe child nodes.
 
String getClassName()
Get the most current class name of that node.
ReturnsThe most current class name.
 
String[] getClassNames()
Get all class names of that node.
ReturnsAn array with all class names of that 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.
 
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 52.1.17).
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[] 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.
 
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 52.1.17).
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 52.1.17).
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.
 
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 getFirstChild()
Get the first child node: an element node, a text node or a comment.
ReturnsThe first child node.
 
Node getFirstElementChild()
Get the first child element (text nodes and comments are skipped).
ReturnsThe first child element.
 
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 getGenericClassName()
Get the generic class name of that node.
ReturnsThe generic class name.
 
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 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.
 
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.
 
Node getNextElementSibling()
Get the next element in the same tree level.
ReturnsThe next element sibling.
 
Node getNextSibling()
Get the next sibling node: An element node, a text node, or a comment node.
ReturnsThe next sibling.
 
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.
 
Node getNthParent(int n)
Get the n-th parent node.
Parameters
nThe parent's level.
ReturnsThe n-th parent or null.
 
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.
 
Node getPreviousElementSibling()
Get the previous element in the same tree level.
ReturnsThe previous element sibling.
 
Node getPreviousSibling()
Get the previous sibling node: An element node, a text node, or a comment node.
ReturnsThe previous sibling.
 
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.
 
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 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 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 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.
 
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.
 
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.
 
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.
 
boolean isBrowserChrome()
Test whether the browser to which the node belongs is a Chrome derivative.
ReturnsTrue for Chrome derivatives, false otherwhise.
 
boolean isBrowserHeadless()
Test whether the browser to which the node belongs is a headless browser.
ReturnsTrue for headless browser, false otherwhise.
 
boolean isBrowserMozilla()
Test whether the browser to which the node belongs is a Mozilla derivative.
ReturnsTrue for Mozilla derivatives, false otherwhise.
 
boolean isBrowserSafari()
Test whether the browser to which the node belongs is a Safari.
ReturnsTrue for Safari, false otherwhise.
 
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.
 
void 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.