Class DomElement

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.w3c.dom.Element, org.w3c.dom.Node
    Direct Known Subclasses:
    HtmlElement

    public class DomElement
    extends DomNamespaceNode
    implements org.w3c.dom.Element
    See Also:
    Serialized Form
    • Field Detail

      • NAME_ATTRIBUTE

        public static final java.lang.String NAME_ATTRIBUTE
        name.
        See Also:
        Constant Field Values
      • VALUE_ATTRIBUTE

        public static final java.lang.String VALUE_ATTRIBUTE
        value.
        See Also:
        Constant Field Values
      • TYPE_ATTRIBUTE

        public static final java.lang.String TYPE_ATTRIBUTE
        type.
        See Also:
        Constant Field Values
      • ATTRIBUTE_NOT_DEFINED

        public static final java.lang.String ATTRIBUTE_NOT_DEFINED
        Constant meaning that the specified attribute was not defined.
      • ATTRIBUTE_VALUE_EMPTY

        public static final java.lang.String ATTRIBUTE_VALUE_EMPTY
        Constant meaning that the specified attribute was found but its value was empty.
    • Constructor Detail

      • DomElement

        public DomElement​(java.lang.String namespaceURI,
                          java.lang.String qualifiedName,
                          SgmlPage page,
                          java.util.Map<java.lang.String,​DomAttr> attributes)
        Creates an instance of a DOM element that can have a namespace.
        Parameters:
        namespaceURI - the URI that identifies an XML namespace
        qualifiedName - the qualified name of the element type to instantiate
        page - the page that contains this element
        attributes - a map ready initialized with the attributes for this element, or null. The map will be stored as is, not copied.
    • Method Detail

      • getNodeName

        public java.lang.String getNodeName()
        Specified by:
        getNodeName in interface org.w3c.dom.Node
      • getNodeType

        public final short getNodeType()
        Specified by:
        getNodeType in interface org.w3c.dom.Node
      • getTagName

        public final java.lang.String getTagName()
        Returns the tag name of this element.
        Specified by:
        getTagName in interface org.w3c.dom.Element
        Returns:
        the tag name of this element
      • hasAttributes

        public final boolean hasAttributes()
        Specified by:
        hasAttributes in interface org.w3c.dom.Node
        Overrides:
        hasAttributes in class DomNode
      • hasAttribute

        public boolean hasAttribute​(java.lang.String attributeName)
        Returns whether the attribute specified by name has a value.
        Specified by:
        hasAttribute in interface org.w3c.dom.Element
        Parameters:
        attributeName - the name of the attribute
        Returns:
        true if an attribute with the given name is specified on this element or has a default value, false otherwise.
      • replaceStyleAttribute

        public void replaceStyleAttribute​(java.lang.String name,
                                          java.lang.String value,
                                          java.lang.String priority)
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Replaces the value of the named style attribute. If there is no style attribute with the specified name, a new one is added. If the specified value is an empty (or all whitespace) string, this method actually removes the named style attribute.
        Parameters:
        name - the attribute name (delimiter-separated, not camel-cased)
        value - the attribute value
        priority - the new priority of the property; "important"or the empty string if none.
      • removeStyleAttribute

        public java.lang.String removeStyleAttribute​(java.lang.String name)
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Removes the specified style attribute, returning the value of the removed attribute.
        Parameters:
        name - the attribute name (delimiter-separated, not camel-cased)
        Returns:
        the removed value
      • getStyleElement

        public org.htmlunit.css.StyleElement getStyleElement​(java.lang.String name)
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Determines the StyleElement for the given name.
        Parameters:
        name - the name of the requested StyleElement
        Returns:
        the StyleElement or null if not found
      • getStyleElementCaseInSensitive

        public org.htmlunit.css.StyleElement getStyleElementCaseInSensitive​(java.lang.String name)
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Determines the StyleElement for the given name. This ignores the case of the name.
        Parameters:
        name - the name of the requested StyleElement
        Returns:
        the StyleElement or null if not found
      • getStyleMap

        public java.util.LinkedHashMap<java.lang.String,​org.htmlunit.css.StyleElement> getStyleMap()
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Returns a sorted map containing style elements, keyed on style element name. We use a LinkedHashMap map so that results are deterministic and are thus testable.
        Returns:
        a sorted map containing style elements, keyed on style element name
      • printOpeningTagContentAsXml

        protected void printOpeningTagContentAsXml​(java.io.PrintWriter printWriter)
        Prints the content between "<" and ">" (or "/>") in the output of the tag name and its attributes in XML format.
        Parameters:
        printWriter - the writer to print in
      • printXml

        protected void printXml​(java.lang.String indent,
                                java.io.PrintWriter printWriter)
        Recursively write the XML data for the node tree starting at node.
        Overrides:
        printXml in class DomNode
        Parameters:
        indent - white space to indent child nodes
        printWriter - writer where child nodes are written
      • isEmptyXmlTagExpanded

        protected boolean isEmptyXmlTagExpanded()
        Indicates if a node without children should be written in expanded form as XML (i.e. with closing tag rather than with "/>")
        Returns:
        false by default
      • getAttribute

        public java.lang.String getAttribute​(java.lang.String attributeName)
        Returns the value of the attribute specified by name or an empty string. If the result is an empty string then it will be either ATTRIBUTE_NOT_DEFINED if the attribute wasn't specified or ATTRIBUTE_VALUE_EMPTY if the attribute was specified but it was empty.
        Specified by:
        getAttribute in interface org.w3c.dom.Element
        Parameters:
        attributeName - the name of the attribute
        Returns:
        the value of the attribute or ATTRIBUTE_NOT_DEFINED or ATTRIBUTE_VALUE_EMPTY
      • getAttributeDirect

        public java.lang.String getAttributeDirect​(java.lang.String attributeName)
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Parameters:
        attributeName - the name of the attribute
        Returns:
        the value of the attribute or ATTRIBUTE_NOT_DEFINED or ATTRIBUTE_VALUE_EMPTY
      • removeAttribute

        public void removeAttribute​(java.lang.String attributeName)
        Removes an attribute specified by name from this element.
        Specified by:
        removeAttribute in interface org.w3c.dom.Element
        Parameters:
        attributeName - the attribute attributeName
      • removeAttributeNS

        public final void removeAttributeNS​(java.lang.String namespaceURI,
                                            java.lang.String localName)
        Removes an attribute specified by namespace and local name from this element.
        Specified by:
        removeAttributeNS in interface org.w3c.dom.Element
        Parameters:
        namespaceURI - the URI that identifies an XML namespace
        localName - the name within the namespace
      • removeAttributeNode

        public final org.w3c.dom.Attr removeAttributeNode​(org.w3c.dom.Attr attribute)
        Not yet implemented.
        Specified by:
        removeAttributeNode in interface org.w3c.dom.Element
      • hasAttributeNS

        public final boolean hasAttributeNS​(java.lang.String namespaceURI,
                                            java.lang.String localName)
        Returns whether the attribute specified by namespace and local name has a value.
        Specified by:
        hasAttributeNS in interface org.w3c.dom.Element
        Parameters:
        namespaceURI - the URI that identifies an XML namespace
        localName - the name within the namespace
        Returns:
        true if an attribute with the given name is specified on this element or has a default value, false otherwise.
      • getAttributesMap

        public final java.util.Map<java.lang.String,​DomAttr> getAttributesMap()
        Returns the map holding the attributes, keyed by name.
        Returns:
        the attributes map
      • getAttributes

        public org.w3c.dom.NamedNodeMap getAttributes()
        Specified by:
        getAttributes in interface org.w3c.dom.Node
        Overrides:
        getAttributes in class DomNode
      • setAttribute

        public void setAttribute​(java.lang.String attributeName,
                                 java.lang.String attributeValue)
        Sets the value of the attribute specified by name.
        Specified by:
        setAttribute in interface org.w3c.dom.Element
        Parameters:
        attributeName - the name of the attribute
        attributeValue - the value of the attribute
      • setAttributeNS

        public void setAttributeNS​(java.lang.String namespaceURI,
                                   java.lang.String qualifiedName,
                                   java.lang.String attributeValue)
        Sets the value of the attribute specified by namespace and qualified name.
        Specified by:
        setAttributeNS in interface org.w3c.dom.Element
        Parameters:
        namespaceURI - the URI that identifies an XML namespace
        qualifiedName - the qualified name (prefix:local) of the attribute
        attributeValue - the value of the attribute
      • setAttributeNS

        protected void setAttributeNS​(java.lang.String namespaceURI,
                                      java.lang.String qualifiedName,
                                      java.lang.String attributeValue,
                                      boolean notifyAttributeChangeListeners,
                                      boolean notifyMutationObservers)
        Sets the value of the attribute specified by namespace and qualified name.
        Parameters:
        namespaceURI - the URI that identifies an XML namespace
        qualifiedName - the qualified name (prefix:local) of the attribute
        attributeValue - the value of the attribute
        notifyAttributeChangeListeners - to notify the associated HtmlAttributeChangeListeners
        notifyMutationObservers - to notify MutationObservers or not
      • isAttributeCaseSensitive

        protected boolean isAttributeCaseSensitive()
        Indicates if the attribute names are case sensitive.
        Returns:
        true
      • getAttributeNS

        public final java.lang.String getAttributeNS​(java.lang.String namespaceURI,
                                                     java.lang.String localName)
        Returns the value of the attribute specified by namespace and local name or an empty string. If the result is an empty string then it will be either ATTRIBUTE_NOT_DEFINED if the attribute wasn't specified or ATTRIBUTE_VALUE_EMPTY if the attribute was specified but it was empty.
        Specified by:
        getAttributeNS in interface org.w3c.dom.Element
        Parameters:
        namespaceURI - the URI that identifies an XML namespace
        localName - the name within the namespace
        Returns:
        the value of the attribute or ATTRIBUTE_NOT_DEFINED or ATTRIBUTE_VALUE_EMPTY
      • getAttributeNode

        public DomAttr getAttributeNode​(java.lang.String name)
        Specified by:
        getAttributeNode in interface org.w3c.dom.Element
      • getAttributeNodeNS

        public DomAttr getAttributeNodeNS​(java.lang.String namespaceURI,
                                          java.lang.String localName)
        Specified by:
        getAttributeNodeNS in interface org.w3c.dom.Element
      • writeStyleToElement

        public void writeStyleToElement​(java.util.Map<java.lang.String,​org.htmlunit.css.StyleElement> styleMap)
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Parameters:
        styleMap - the styles
      • getElementsByTagName

        public DomNodeList<HtmlElement> getElementsByTagName​(java.lang.String tagName)
        Specified by:
        getElementsByTagName in interface org.w3c.dom.Element
      • getElementsByTagNameNS

        public DomNodeList<HtmlElement> getElementsByTagNameNS​(java.lang.String namespace,
                                                               java.lang.String localName)
        Not yet implemented.
        Specified by:
        getElementsByTagNameNS in interface org.w3c.dom.Element
      • getSchemaTypeInfo

        public org.w3c.dom.TypeInfo getSchemaTypeInfo()
        Not yet implemented.
        Specified by:
        getSchemaTypeInfo in interface org.w3c.dom.Element
      • setIdAttribute

        public void setIdAttribute​(java.lang.String name,
                                   boolean isId)
        Not yet implemented.
        Specified by:
        setIdAttribute in interface org.w3c.dom.Element
      • setIdAttributeNS

        public void setIdAttributeNS​(java.lang.String namespaceURI,
                                     java.lang.String localName,
                                     boolean isId)
        Not yet implemented.
        Specified by:
        setIdAttributeNS in interface org.w3c.dom.Element
      • setAttributeNode

        public org.w3c.dom.Attr setAttributeNode​(org.w3c.dom.Attr attribute)
        Specified by:
        setAttributeNode in interface org.w3c.dom.Element
      • setAttributeNodeNS

        public org.w3c.dom.Attr setAttributeNodeNS​(org.w3c.dom.Attr attribute)
        Not yet implemented.
        Specified by:
        setAttributeNodeNS in interface org.w3c.dom.Element
      • setIdAttributeNode

        public final void setIdAttributeNode​(org.w3c.dom.Attr idAttr,
                                             boolean isId)
        Not yet implemented.
        Specified by:
        setIdAttributeNode in interface org.w3c.dom.Element
      • cloneNode

        public DomNode cloneNode​(boolean deep)
        Specified by:
        cloneNode in interface org.w3c.dom.Node
        Overrides:
        cloneNode in class DomNode
      • getId

        public final java.lang.String getId()
        Returns:
        the identifier of this element
      • setId

        public final void setId​(java.lang.String newId)
        Sets the identifier this element.
        Parameters:
        newId - the new identifier of this element
      • getFirstElementChild

        public DomElement getFirstElementChild()
        Returns the first child element node of this element. null if this element has no child elements.
        Returns:
        the first child element node of this element. null if this element has no child elements
      • getLastElementChild

        public DomElement getLastElementChild()
        Returns the last child element node of this element. null if this element has no child elements.
        Returns:
        the last child element node of this element. null if this element has no child elements
      • getChildElementCount

        public int getChildElementCount()
        Returns the current number of element nodes that are children of this element.
        Returns:
        the current number of element nodes that are children of this element.
      • getChildElements

        public final java.lang.Iterable<DomElement> getChildElements()
        Returns:
        an Iterable over the DomElement children of this object, i.e. excluding the non-element nodes
      • toString

        public java.lang.String toString()
        Returns a string representation of this element.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of this element
      • click

        public <P extends Page> P click()
                                 throws java.io.IOException
        Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.
        This only clicks the element if it is visible and enabled (isDisplayed() & !isDisabled()). In case the element is not visible and/or disabled, only a log output is generated.
        If you circumvent the visible/disabled check use click(shiftKey, ctrlKey, altKey, true, true, false)
        Type Parameters:
        P - the page type
        Returns:
        the page contained in the current window as returned by WebClient.getCurrentWindow()
        Throws:
        java.io.IOException - if an IO error occurs
      • click

        public <P extends Page> P click​(boolean shiftKey,
                                        boolean ctrlKey,
                                        boolean altKey)
                                 throws java.io.IOException
        Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.
        This only clicks the element if it is visible and enabled (isDisplayed() & !isDisabled()). In case the element is not visible and/or disabled, only a log output is generated.
        If you circumvent the visible/disabled check use click(shiftKey, ctrlKey, altKey, true, true, false)
        Type Parameters:
        P - the page type
        Parameters:
        shiftKey - true if SHIFT is pressed during the click
        ctrlKey - true if CTRL is pressed during the click
        altKey - true if ALT is pressed during the click
        Returns:
        the page contained in the current window as returned by WebClient.getCurrentWindow()
        Throws:
        java.io.IOException - if an IO error occurs
      • click

        public <P extends Page> P click​(boolean shiftKey,
                                        boolean ctrlKey,
                                        boolean altKey,
                                        boolean triggerMouseEvents)
                                 throws java.io.IOException
        Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.
        This only clicks the element if it is visible and enabled (isDisplayed() & !isDisabled()). In case the element is not visible and/or disabled, only a log output is generated.
        If you circumvent the visible/disabled check use click(shiftKey, ctrlKey, altKey, true, true, false)
        Type Parameters:
        P - the page type
        Parameters:
        shiftKey - true if SHIFT is pressed during the click
        ctrlKey - true if CTRL is pressed during the click
        altKey - true if ALT is pressed during the click
        triggerMouseEvents - if true trigger the mouse events also
        Returns:
        the page contained in the current window as returned by WebClient.getCurrentWindow()
        Throws:
        java.io.IOException - if an IO error occurs
      • isDisabledElementAndDisabled

        protected boolean isDisabledElementAndDisabled()
        Returns:
        true if this is an DisabledElement and disabled
      • click

        public <P extends Page> P click​(boolean shiftKey,
                                        boolean ctrlKey,
                                        boolean altKey,
                                        boolean triggerMouseEvents,
                                        boolean handleFocus,
                                        boolean ignoreVisibility,
                                        boolean disableProcessLabelAfterBubbling)
                                 throws java.io.IOException
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.
        Type Parameters:
        P - the page type
        Parameters:
        shiftKey - true if SHIFT is pressed during the click
        ctrlKey - true if CTRL is pressed during the click
        altKey - true if ALT is pressed during the click
        triggerMouseEvents - if true trigger the mouse events also
        handleFocus - if true set the focus (and trigger the event)
        ignoreVisibility - whether to ignore visibility or not
        disableProcessLabelAfterBubbling - ignore label processing
        Returns:
        the page contained in the current window as returned by WebClient.getCurrentWindow()
        Throws:
        java.io.IOException - if an IO error occurs
      • getEventTargetElement

        protected DomNode getEventTargetElement()
        Returns the event target element. This could be overridden by subclasses to have other targets. The default implementation returns 'this'.
        Returns:
        the event target element.
      • click

        public <P extends Page> P click​(org.htmlunit.javascript.host.event.Event event,
                                        boolean shiftKey,
                                        boolean ctrlKey,
                                        boolean altKey,
                                        boolean ignoreVisibility)
                                 throws java.io.IOException
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.
        Type Parameters:
        P - the page type
        Parameters:
        event - the click event used
        shiftKey - true if SHIFT is pressed during the click
        ctrlKey - true if CTRL is pressed during the click
        altKey - true if ALT is pressed during the click
        ignoreVisibility - whether to ignore visibility or not
        Returns:
        the page contained in the current window as returned by WebClient.getCurrentWindow()
        Throws:
        java.io.IOException - if an IO error occurs
      • doClickStateUpdate

        protected boolean doClickStateUpdate​(boolean shiftKey,
                                             boolean ctrlKey)
                                      throws java.io.IOException
        This method implements the control state update part of the click action.

        The default implementation only calls doClickStateUpdate on parent's DomElement (if any). Subclasses requiring different behavior (like HtmlSubmitInput) will override this method.

        Parameters:
        shiftKey - true if SHIFT is pressed
        ctrlKey - true if CTRL is pressed
        Returns:
        true if doClickFireEvent method has to be called later on (to signal, that the value was changed)
        Throws:
        java.io.IOException - if an IO error occurs
      • doClickFireChangeEvent

        protected void doClickFireChangeEvent()
        This method implements the control onchange handler call during the click action.
      • doClickFireClickEvent

        protected ScriptResult doClickFireClickEvent​(org.htmlunit.javascript.host.event.Event event)
        This method implements the control onclick handler call during the click action.
        Parameters:
        event - the click event used
        Returns:
        the script result
      • dblClick

        public <P extends Page> P dblClick()
                                    throws java.io.IOException
        Simulates double-clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc. Note also that click() is automatically called first.
        Type Parameters:
        P - the page type
        Returns:
        the page that occupies this element's window after the element has been double-clicked
        Throws:
        java.io.IOException - if an IO error occurs
      • dblClick

        public <P extends Page> P dblClick​(boolean shiftKey,
                                           boolean ctrlKey,
                                           boolean altKey)
                                    throws java.io.IOException
        Simulates double-clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc. Note also that click(boolean, boolean, boolean) is automatically called first.
        Type Parameters:
        P - the page type
        Parameters:
        shiftKey - true if SHIFT is pressed during the double-click
        ctrlKey - true if CTRL is pressed during the double-click
        altKey - true if ALT is pressed during the double-click
        Returns:
        the page that occupies this element's window after the element has been double-clicked
        Throws:
        java.io.IOException - if an IO error occurs
      • mouseOver

        public Page mouseOver()
        Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Returns:
        the page which this element's window contains after the mouse move
      • mouseOver

        public Page mouseOver​(boolean shiftKey,
                              boolean ctrlKey,
                              boolean altKey,
                              int button)
        Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Parameters:
        shiftKey - true if SHIFT is pressed during the mouse move
        ctrlKey - true if CTRL is pressed during the mouse move
        altKey - true if ALT is pressed during the mouse move
        button - the button code, must be MouseEvent.BUTTON_LEFT, MouseEvent.BUTTON_MIDDLE or MouseEvent.BUTTON_RIGHT
        Returns:
        the page which this element's window contains after the mouse move
      • mouseMove

        public Page mouseMove()
        Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Returns:
        the page which this element's window contains after the mouse move
      • mouseMove

        public Page mouseMove​(boolean shiftKey,
                              boolean ctrlKey,
                              boolean altKey,
                              int button)
        Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Parameters:
        shiftKey - true if SHIFT is pressed during the mouse move
        ctrlKey - true if CTRL is pressed during the mouse move
        altKey - true if ALT is pressed during the mouse move
        button - the button code, must be MouseEvent.BUTTON_LEFT, MouseEvent.BUTTON_MIDDLE or MouseEvent.BUTTON_RIGHT
        Returns:
        the page which this element's window contains after the mouse move
      • mouseOut

        public Page mouseOut()
        Simulates moving the mouse out of this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Returns:
        the page which this element's window contains after the mouse move
      • mouseOut

        public Page mouseOut​(boolean shiftKey,
                             boolean ctrlKey,
                             boolean altKey,
                             int button)
        Simulates moving the mouse out of this element, returning the page which this element's window contains after the mouse move. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Parameters:
        shiftKey - true if SHIFT is pressed during the mouse move
        ctrlKey - true if CTRL is pressed during the mouse move
        altKey - true if ALT is pressed during the mouse move
        button - the button code, must be MouseEvent.BUTTON_LEFT, MouseEvent.BUTTON_MIDDLE or MouseEvent.BUTTON_RIGHT
        Returns:
        the page which this element's window contains after the mouse move
      • mouseDown

        public Page mouseDown()
        Simulates clicking the mouse on this element, returning the page which this element's window contains after the mouse click. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Returns:
        the page which this element's window contains after the mouse click
      • mouseDown

        public Page mouseDown​(boolean shiftKey,
                              boolean ctrlKey,
                              boolean altKey,
                              int button)
        Simulates clicking the mouse on this element, returning the page which this element's window contains after the mouse click. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Parameters:
        shiftKey - true if SHIFT is pressed during the mouse click
        ctrlKey - true if CTRL is pressed during the mouse click
        altKey - true if ALT is pressed during the mouse click
        button - the button code, must be MouseEvent.BUTTON_LEFT, MouseEvent.BUTTON_MIDDLE or MouseEvent.BUTTON_RIGHT
        Returns:
        the page which this element's window contains after the mouse click
      • mouseUp

        public Page mouseUp()
        Simulates releasing the mouse click on this element, returning the page which this element's window contains after the mouse click release. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Returns:
        the page which this element's window contains after the mouse click release
      • mouseUp

        public Page mouseUp​(boolean shiftKey,
                            boolean ctrlKey,
                            boolean altKey,
                            int button)
        Simulates releasing the mouse click on this element, returning the page which this element's window contains after the mouse click release. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Parameters:
        shiftKey - true if SHIFT is pressed during the mouse click release
        ctrlKey - true if CTRL is pressed during the mouse click release
        altKey - true if ALT is pressed during the mouse click release
        button - the button code, must be MouseEvent.BUTTON_LEFT, MouseEvent.BUTTON_MIDDLE or MouseEvent.BUTTON_RIGHT
        Returns:
        the page which this element's window contains after the mouse click release
      • rightClick

        public Page rightClick()
        Simulates right clicking the mouse on this element, returning the page which this element's window contains after the mouse click. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Returns:
        the page which this element's window contains after the mouse click
      • rightClick

        public Page rightClick​(boolean shiftKey,
                               boolean ctrlKey,
                               boolean altKey)
        Simulates right clicking the mouse on this element, returning the page which this element's window contains after the mouse click. The returned page may or may not be the same as the original page, depending on JavaScript event handlers, etc.
        Parameters:
        shiftKey - true if SHIFT is pressed during the mouse click
        ctrlKey - true if CTRL is pressed during the mouse click
        altKey - true if ALT is pressed during the mouse click
        Returns:
        the page which this element's window contains after the mouse click
      • fireEvent

        public ScriptResult fireEvent​(java.lang.String eventType)
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Shortcut for fireEvent(Event).
        Parameters:
        eventType - the event type (like "load", "click")
        Returns:
        the execution result, or null if nothing is executed
      • fireEvent

        public ScriptResult fireEvent​(org.htmlunit.javascript.host.event.Event event)
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Fires the event on the element. Nothing is done if JavaScript is disabled.
        Parameters:
        event - the event to fire
        Returns:
        the execution result, or null if nothing is executed
      • preventDefault

        protected void preventDefault()
        This method is called if the current fired event is canceled by preventDefault() in FireFox, or by returning false in Internet Explorer.

        The default implementation does nothing.

      • focus

        public void focus()
        Sets the focus on this element.
      • blur

        public void blur()
        Removes focus from this element.
      • removeFocus

        public void removeFocus()
        INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
        Gets notified that it has lost the focus.
      • isStateUpdateFirst

        protected boolean isStateUpdateFirst()
        Returns true if state updates should be done before onclick event handling. This method returns false by default, and is expected to be overridden to return true by derived classes like HtmlCheckBoxInput.
        Returns:
        true if state updates should be done before onclick event handling
      • isMouseOver

        public boolean isMouseOver()
        Returns whether the Mouse is currently over this element or not.
        Returns:
        whether the Mouse is currently over this element or not
      • matches

        public boolean matches​(java.lang.String selectorString)
        Returns true if the element would be selected by the specified selector string; otherwise, returns false.
        Parameters:
        selectorString - the selector to test
        Returns:
        true if the element would be selected by the specified selector string; otherwise, returns false.
      • setNodeValue

        public void setNodeValue​(java.lang.String value)
        Specified by:
        setNodeValue in interface org.w3c.dom.Node
      • setDefaults

        public void setDefaults​(org.htmlunit.css.ComputedCssStyleDeclaration style)
        Callback method which allows different HTML element types to perform custom initialization of computed styles. For example, body elements in most browsers have default values for their margins.
        Parameters:
        style - the style to initialize
      • setInnerHtml

        public void setInnerHtml​(java.lang.String source)
                          throws org.xml.sax.SAXException,
                                 java.io.IOException
        Replaces all child elements of this element with the supplied value parsed as html.
        Parameters:
        source - the new value for the contents of this element
        Throws:
        org.xml.sax.SAXException - in case of error
        java.io.IOException - in case of error