Manual

43.1.2
The DocumentNode class

The DocumentNode class is derived from Node and also resides in the package de.qfs.apps.qftest.client.web.dom. In addition to the methods defined in the Node class and explained above, DocumentNode provides the following:

 
 
boolean hasParent()
To test whether a document is a top-level document this method should be used instead of testing whether the result of getParent() is null. The reason is that loading of nested child documents may be completed before loading of the main document. During this time it is known that the nested document will have a parent, but the parent is not available yet.
Returns True if the document has a parent, false if it is a top-level document.
 
DomNode getRootElement()
Get the <HTML> root element of the document.
ReturnsThe root element of the document.
 
FrameNode[] getFrames()
Get the child frames of the document.
Returns The child frames of the document, an empty array in case there are none.
 
String getUrl()
Get the URL of the document.
ReturnsThe URL of the document.
 
String getTitle()
Get the title of the document as defined in the <TITLE> of the <HEAD> of its root element.
ReturnsThe title of the document.
 
String getSourcecode()
Get the HTML source code of the document in its current state, which is not necessarily the same as what was loaded when the document was opened because attributes or the DOM's structure may have been changes since, e.g. via JavaScript.
Returns The current HTML code of the document.
 
Object evalJS(String script)
Evaluate some JavaScript code in the context of this document.
Parameters
scriptThe script to execute.
ReturnsWhatever the script returns, converted to the proper object type. Even returning a DOM node, frame or document works.
 
boolean hasCSSClass(String cl)
Check, whether the node has a specified css-class.
Parameters
clThe name of the css-class.
ReturnsTrue, if the node has this css-class, otherwise false.
 
DomNode getByXPath(String xpath)
Get a node, which is determined via XPath.
Parameters
xpathXPath starting from that node.
ReturnsThe found node or null.
 
DomNode[] getAllByXPath(String xpath)
Get all nodes, which are determined via XPath.
Parameters
xpathXPath starting from that node.
ReturnsAn array of all found nodes or null.
 
DomNode getByCSS(String css)
Get a node, which is determined via a CSS-selector.
Parameters
cssCSS-selector starting from that node.
ReturnsThe found node or null.
 
DomNode[] getAllByCSS(String css)
Get all nodes, which are determined via CSS-selectors.
Parameters
cssCSS-selector starting from that node.
ReturnsAn array of all found nodes or null.
 
 

In addition to the instance methods describe above, the DocumentNode class provides some static convenience methods for manipulating URLs.

 
 
static String getUrlBase(String url)
Get the base part of an URL, including host and directory but excluding possible parameters separated by '?' and excluding a possible Tomcat session ID.
Parameters
urlThe URL to get the base part of.
ReturnsThe base part of the URL.
 
static String getUrlHost(String url)
Get the host part of an URL, i.e. the part between "http(s)://" and the next '/'.
Parameters
urlThe URL to get the host part of.
Returns The host part of the URL or null if the protocol is neither http nor https.
 
static String normalizeUrl(String url)
Normalize an URL by replacing '\' with '/', "file:/(/(/))" with "file:///", up-casing windows drive letters and decoding %.. sequences.
Parameters
urlThe URL to normalize.
Returns The normalized URL.
 
static ExtraFeatureSet getUrlParameters(String url)
Get the parameters of an URL, including those separated by '?' and a possible Tomcat session ID, in the form of an ExtraFeatureSet that can be used for an ExtraFeatureResolver as described in subsection 44.1.10.
Parameters
urlThe URL to get the parameters for.
Returns The parameters of the URL.