public interface Document extends Node
Modifier and Type | Method and Description |
---|---|
java.lang.String |
baseUri()
Returns a string that represents the
<base> element's href attribute if one
is present. |
Element |
createElement(java.lang.String tagName)
Creates and returns a new DOM element with the given
tagName . |
Event |
createEvent(EventType eventType,
EventParams params)
|
KeyEvent |
createKeyDownEvent(KeyEventParams params)
|
KeyEvent |
createKeyPressEvent(KeyEventParams params)
|
KeyEvent |
createKeyUpEvent(KeyEventParams params)
|
MouseEvent |
createMouseEvent(EventType eventType,
MouseEventParams params)
Creates and returns a new
MouseEvent object with the given eventType and
params . |
Node |
createTextNode()
Creates and returns a
Node object representing a new text node with
an empty node value. |
Node |
createTextNode(java.lang.String text)
Creates and returns a
Node object representing a new text node initialized with the
given text value. |
WheelEvent |
createWheelEvent(EventType eventType,
WheelEventParams params)
Creates and returns a new
WheelEvent object with the given eventType and
params . |
java.util.Optional<Element> |
documentElement()
Returns an
Optional that contains the document HTML element that usually represents
HTML tag, otherwise an empty Optional if the document element is not available. |
java.util.Optional<Element> |
focusedElement()
Returns an
Optional that contains the currently focused element in the document,
otherwise an empty Optional if there is no focused element in this document. |
Frame |
frame()
Returns the
Frame instance of this document. |
appendChild, children, click, close, compareDocumentPosition, document, evaluate, evaluate, insertChild, nextSibling, nodeName, nodeValue, nodeValue, parent, previousSibling, removeChild, replaceChild, textContent, textContent, type, xPath
addEventListener, dispatch, eventListeners, removeEventListener
findElementByClassName, findElementByCssSelector, findElementById, findElementByName, findElementByTagName, findElementsByClassName, findElementsByCssSelector, findElementsById, findElementsByName, findElementsByTagName
Frame frame()
Frame
instance of this document.java.util.Optional<Element> documentElement()
Optional
that contains the document HTML element that usually represents
HTML tag, otherwise an empty Optional
if the document element is not available.ObjectClosedException
- when the document is closedElement createElement(java.lang.String tagName)
tagName
.tagName
- a string that represents a tag name (e.g. "A", "P", "DIV") of the
new DOM elementElement
instancejava.lang.IllegalArgumentException
- when tagName
is empty or blankObjectClosedException
- when the document is closedNode createTextNode()
Node
object representing a new text node with
an empty node value.ObjectClosedException
- when the document is closedNode createTextNode(java.lang.String text)
Node
object representing a new text node initialized with the
given text
value.text
- the node valueObjectClosedException
- when the document is closedEvent createEvent(EventType eventType, EventParams params)
eventType
- an EventType
object representing a type of a DOM event
supported by engineparams
- an EventParams
object representing DOM event properties (e.g.
bubbles, cancellable)ObjectClosedException
- when the document is closedEventTarget.dispatch(Event)
MouseEvent createMouseEvent(EventType eventType, MouseEventParams params)
MouseEvent
object with the given eventType
and
params
.eventType
- an EventType
object representing a type of a valid DOM event
supported by engineparams
- an MouseEventParams
object representing mouse event propertiesMouseEvent
objectjava.lang.IllegalArgumentException
- if the event creation failed due to the invalid event paramsObjectClosedException
- when the document is closedWheelEvent createWheelEvent(EventType eventType, WheelEventParams params)
WheelEvent
object with the given eventType
and
params
.eventType
- an EventType
object representing a type of a valid DOM event
supported by engineparams
- an WheelEventParams
object representing wheel event propertiesWheelEvent
objectjava.lang.IllegalArgumentException
- if the event creation failed due to the invalid event paramsObjectClosedException
- when the document is closedKeyEvent createKeyUpEvent(KeyEventParams params)
params
- the key event parametersKeyEvent
instancejava.lang.IllegalArgumentException
- if the event creation has been failedObjectClosedException
- when the document is closedKeyEvent createKeyDownEvent(KeyEventParams params)
params
- the key event parametersKeyEvent
instancejava.lang.IllegalArgumentException
- if the event creation has been failedObjectClosedException
- when the document is closedKeyEvent createKeyPressEvent(KeyEventParams params)
params
- the key event parametersKeyEvent
instancejava.lang.IllegalArgumentException
- if the event creation has been failedObjectClosedException
- when the document is closedjava.lang.String baseUri()
<base>
element's href
attribute if one
is present. If the currently loaded document does not have the <base>
element, the
method returns URL of the currently loaded document including "about:blank" when nothing is
loaded.ObjectClosedException
- when the document is closedjava.util.Optional<Element> focusedElement()
Optional
that contains the currently focused element in the document,
otherwise an empty Optional
if there is no focused element in this document.ObjectClosedException
- when the document is closed