Interface Document

All Superinterfaces:
EventTarget, Node, SearchContext

public interface Document extends Node
An HTML DOM document.
  • Method Details

    • frame

      Frame frame()
      Returns the Frame instance of this document.
    • documentElement

      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.
      Throws:
      ObjectClosedException - when the document is closed
    • createElement

      Element createElement(String tagName)
      Creates and returns a new DOM element with the given tagName.
      Parameters:
      tagName - a string that represents a tag name (e.g. "A", "P", "DIV") of the new DOM element
      Returns:
      a new Element instance
      Throws:
      IllegalArgumentException - when tagName is empty or blank
      ObjectClosedException - when the document is closed
    • createTextNode

      Node createTextNode()
      Creates and returns a Node object representing a new text node with an empty node value.
      Throws:
      ObjectClosedException - when the document is closed
    • createTextNode

      Node createTextNode(String text)
      Creates and returns a Node object representing a new text node initialized with the given text value.
      Parameters:
      text - the node value
      Throws:
      ObjectClosedException - when the document is closed
    • createEvent

      Event createEvent(EventType eventType, EventParams params)
      Creates and returns a new Event object with the given eventType and params.
      Parameters:
      eventType - an EventType object representing a type of a DOM event supported by engine
      params - an EventParams object representing DOM event properties (e.g. bubbles, cancellable)
      Throws:
      ObjectClosedException - when the document is closed
      See Also:
    • createMouseEvent

      MouseEvent createMouseEvent(EventType eventType, MouseEventParams params)
      Creates and returns a new MouseEvent object with the given eventType and params.
      Parameters:
      eventType - an EventType object representing a type of a valid DOM event supported by engine
      params - an MouseEventParams object representing mouse event properties
      Returns:
      a new MouseEvent object
      Throws:
      IllegalArgumentException - if the event creation failed due to the invalid event params
      ObjectClosedException - when the document is closed
    • createWheelEvent

      WheelEvent createWheelEvent(EventType eventType, WheelEventParams params)
      Creates and returns a new WheelEvent object with the given eventType and params.
      Parameters:
      eventType - an EventType object representing a type of a valid DOM event supported by engine
      params - an WheelEventParams object representing wheel event properties
      Returns:
      a new WheelEvent object
      Throws:
      IllegalArgumentException - if the event creation failed due to the invalid event params
      ObjectClosedException - when the document is closed
    • createKeyUpEvent

      KeyEvent createKeyUpEvent(KeyEventParams params)
      Creates a new KeyEvent instance with the EventType.KEY_UP event type and the given params.
      Parameters:
      params - the key event parameters
      Returns:
      a new KeyEvent instance
      Throws:
      IllegalArgumentException - if the event creation has been failed
      ObjectClosedException - when the document is closed
    • createKeyDownEvent

      KeyEvent createKeyDownEvent(KeyEventParams params)
      Creates a new KeyEvent instance with the EventType.KEY_DOWN event type and the given params.
      Parameters:
      params - the key event parameters
      Returns:
      a new KeyEvent instance
      Throws:
      IllegalArgumentException - if the event creation has been failed
      ObjectClosedException - when the document is closed
    • createKeyPressEvent

      KeyEvent createKeyPressEvent(KeyEventParams params)
      Creates a new KeyEvent instance with the EventType.KEY_PRESS event type and the given params.
      Parameters:
      params - the key event parameters
      Returns:
      a new KeyEvent instance
      Throws:
      IllegalArgumentException - if the event creation has been failed
      ObjectClosedException - when the document is closed
    • baseUri

      String baseUri()
      Returns a string that represents the <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.
      Throws:
      ObjectClosedException - when the document is closed
    • focusedElement

      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.
      Throws:
      ObjectClosedException - when the document is closed
      Since:
      7.10