Package org.htmlunit.html
Class DomElement
java.lang.Object
org.htmlunit.html.DomNode
org.htmlunit.html.DomNamespaceNode
org.htmlunit.html.DomElement
- All Implemented Interfaces:
Serializable
,Cloneable
,Element
,Node
- Direct Known Subclasses:
HtmlElement
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
An iterator over the DomElement children.Nested classes/interfaces inherited from class org.htmlunit.html.DomNode
DomNode.ChildIterator, DomNode.DescendantDomElementsIterator, DomNode.DescendantDomNodesIterator, DomNode.DescendantElementsIterator<T extends DomNode>, DomNode.DescendantHtmlElementsIterator
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Constant meaning that the specified attribute was not defined.static final String
Constant meaning that the specified attribute was found but its value was empty.static final String
id.static final String
name.static final String
src.static final String
type.static final String
value.Fields inherited from class org.htmlunit.html.DomNode
PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
blur()
Removes focus from this element.<P extends Page>
Pclick()
Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked.<P extends Page>
Pclick
(boolean shiftKey, boolean ctrlKey, boolean altKey) Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked.<P extends Page>
Pclick
(boolean shiftKey, boolean ctrlKey, boolean altKey, boolean triggerMouseEvents) Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked.<P extends Page>
Pclick
(boolean shiftKey, boolean ctrlKey, boolean altKey, boolean triggerMouseEvents, boolean handleFocus, boolean ignoreVisibility, boolean disableProcessLabelAfterBubbling) 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.<P extends Page>
Pclick
(org.htmlunit.javascript.host.event.Event event, boolean shiftKey, boolean ctrlKey, boolean altKey, boolean ignoreVisibility) 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.cloneNode
(boolean deep) <P extends Page>
PdblClick()
Simulates double-clicking on this element, returning the page in the window that has the focus after the element has been clicked.<P extends Page>
PdblClick
(boolean shiftKey, boolean ctrlKey, boolean altKey) Simulates double-clicking on this element, returning the page in the window that has the focus after the element has been clicked.protected void
This method implements the control onchange handler call during the click action.protected ScriptResult
doClickFireClickEvent
(org.htmlunit.javascript.host.event.Event event) This method implements the control onclick handler call during the click action.protected boolean
doClickStateUpdate
(boolean shiftKey, boolean ctrlKey) This method implements the control state update part of the click action.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.void
focus()
Sets the focus on this element.getAttribute
(String attributeName) Returns the value of the attribute specified by name or an empty string.getAttributeDirect
(String attributeName) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.getAttributeNode
(String name) getAttributeNodeNS
(String namespaceURI, String localName) final String
getAttributeNS
(String namespaceURI, String localName) Returns the value of the attribute specified by namespace and local name or an empty string.Returns the map holding the attributes, keyed by name.int
Returns the current number of element nodes that are children of this element.final Iterable
<DomElement> getElementsByTagName
(String tagName) getElementsByTagNameNS
(String namespace, String localName) Not yet implemented.protected DomNode
Returns the event target element.Returns the first child element node of this element. null if this element has no child elements.final String
getId()
Returns the last child element node of this element. null if this element has no child elements.final short
Not yet implemented.<E extends HtmlElement>
List<E> getStaticElementsByTagName
(String tagName) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.org.htmlunit.css.StyleElement
getStyleElement
(String name) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Determines the StyleElement for the given name.org.htmlunit.css.StyleElement
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Determines the StyleElement for the given name.LinkedHashMap
<String, org.htmlunit.css.StyleElement> 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.final String
Returns the tag name of this element.boolean
hasAttribute
(String attributeName) Returns whether the attribute specified by name has a value.final boolean
hasAttributeNS
(String namespaceURI, String localName) Returns whether the attribute specified by namespace and local name has a value.final boolean
protected boolean
Indicates if the attribute names are case sensitive.protected boolean
protected boolean
Indicates if a node without children should be written in expanded form as XML (i.e. with closing tag rather than with "/>")boolean
Returns whether the Mouse is currently over this element or not.protected boolean
Returnstrue
if state updates should be done before onclick event handling.boolean
Returns true if the element would be selected by the specified selector string; otherwise, returns false.Simulates clicking the mouse on this element, returning the page which this element's window contains after the mouse click.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.Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move.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.mouseOut()
Simulates moving the mouse out of this element, returning the page which this element's window contains after the mouse move.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.Simulates moving the mouse over this element, returning the page which this element's window contains after the mouse move.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.mouseUp()
Simulates releasing the mouse click on this element, returning the page which this element's window contains after the mouse click release.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.protected void
This method is called if the current fired event is canceled bypreventDefault()
.protected void
printOpeningTagContentAsXml
(PrintWriter printWriter) Prints the content between "<" and ">" (or "/>") in the output of the tag name and its attributes in XML format.protected void
printXml
(String indent, PrintWriter printWriter) Recursively write the XML data for the node tree starting atnode
.protected boolean
void
removeAttribute
(String attributeName) Removes an attribute specified by name from this element.final Attr
removeAttributeNode
(Attr attribute) Not yet implemented.final void
removeAttributeNS
(String namespaceURI, String localName) Removes an attribute specified by namespace and local name from this element.void
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Gets notified that it has lost the focus.removeStyleAttribute
(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.void
replaceStyleAttribute
(String name, String value, String priority) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Replaces the value of the named style attribute.Simulates right clicking the mouse on this element, returning the page which this element's window contains after the mouse click.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.void
setAttribute
(String attributeName, String attributeValue) Sets the value of the attribute specified by name.setAttributeNode
(Attr attribute) setAttributeNodeNS
(Attr attribute) Not yet implemented.void
setAttributeNS
(String namespaceURI, String qualifiedName, String attributeValue) Sets the value of the attribute specified by namespace and qualified name.protected void
setAttributeNS
(String namespaceURI, String qualifiedName, String attributeValue, boolean notifyAttributeChangeListeners, boolean notifyMutationObservers) Sets the value of the attribute specified by namespace and qualified name.void
setDefaults
(org.htmlunit.css.ComputedCssStyleDeclaration style) Callback method which allows different HTML element types to perform custom initialization of computed styles.final void
Sets the identifier this element.void
setIdAttribute
(String name, boolean isId) Not yet implemented.final void
setIdAttributeNode
(Attr idAttr, boolean isId) Not yet implemented.void
setIdAttributeNS
(String namespaceURI, String localName, boolean isId) Not yet implemented.void
setInnerHtml
(String source) Replaces all child elements of this element with the supplied value parsed as html.void
setNodeValue
(String value) toString()
Returns a string representation of this element.void
writeStyleToElement
(Map<String, org.htmlunit.css.StyleElement> styleMap) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.Methods inherited from class org.htmlunit.html.DomNamespaceNode
getLocalName, getLowercaseName, getNamespaceURI, getPrefix, getQualifiedName, processImportNode, setPrefix
Methods inherited from class org.htmlunit.html.DomNode
addCharacterDataChangeListener, addDomChangeListener, appendChild, asNormalizedText, asXml, basicRemove, checkChildHierarchy, closest, compareDocumentPosition, detach, fireCharacterDataChanged, fireNodeAdded, fireNodeDeleted, getAncestors, getBaseURI, getByXPath, getByXPath, getCanonicalXPath, getChildNodes, getChildren, getDescendants, getDomElementDescendants, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstByXPath, getFirstChild, getHtmlElementDescendants, getHtmlPageOrNull, getIndex, getLastChild, getNextElementSibling, getNextSibling, getNodeValue, getOwnerDocument, getPage, getParentNode, getPreviousElementSibling, getPreviousSibling, getReadyState, getScriptableObject, getSelectorList, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, getVisibleText, handles, hasChildNodes, hasFeature, insertBefore, insertBefore, isAncestorOf, isAncestorOfAny, isAttachedToPage, isDefaultNamespace, isDisplayed, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, mayBeDisplayed, normalize, notifyIncorrectness, onAddedToDocumentFragment, onAddedToPage, onAllChildrenAddedToPage, parseHtmlSnippet, printChildrenAsXml, querySelector, querySelectorAll, quietlyRemoveAndMoveChildrenTo, remove, removeAllChildren, removeCharacterDataChangeListener, removeChild, removeDomChangeListener, replace, replaceChild, setEndLocation, setParentNode, setReadyState, setScriptableObject, setStartLocation, setTextContent, setUserData
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setPrefix, setTextContent, setUserData
-
Field Details
-
ID_ATTRIBUTE
id.- See Also:
-
NAME_ATTRIBUTE
name.- See Also:
-
SRC_ATTRIBUTE
src.- See Also:
-
VALUE_ATTRIBUTE
value.- See Also:
-
TYPE_ATTRIBUTE
type.- See Also:
-
ATTRIBUTE_NOT_DEFINED
Constant meaning that the specified attribute was not defined. -
ATTRIBUTE_VALUE_EMPTY
Constant meaning that the specified attribute was found but its value was empty.
-
-
Constructor Details
-
DomElement
public DomElement(String namespaceURI, String qualifiedName, SgmlPage page, Map<String, DomAttr> attributes) Creates an instance of a DOM element that can have a namespace.- Parameters:
namespaceURI
- the URI that identifies an XML namespacequalifiedName
- the qualified name of the element type to instantiatepage
- the page that contains this elementattributes
- a map ready initialized with the attributes for this element, ornull
. The map will be stored as is, not copied.
-
-
Method Details
-
getNodeName
- Specified by:
getNodeName
in interfaceNode
-
getNodeType
public final short getNodeType()- Specified by:
getNodeType
in interfaceNode
-
getTagName
Returns the tag name of this element.- Specified by:
getTagName
in interfaceElement
- Returns:
- the tag name of this element
-
hasAttributes
public final boolean hasAttributes()- Specified by:
hasAttributes
in interfaceNode
- Overrides:
hasAttributes
in classDomNode
-
hasAttribute
Returns whether the attribute specified by name has a value.- Specified by:
hasAttribute
in interfaceElement
- 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
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 valuepriority
- the new priority of the property;"important"
or the empty string if none.
-
removeStyleAttribute
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
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
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
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 aLinkedHashMap
map so that results are deterministic and are thus testable.- Returns:
- a sorted map containing style elements, keyed on style element name
-
printOpeningTagContentAsXml
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
Recursively write the XML data for the node tree starting atnode
. -
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
Returns the value of the attribute specified by name or an empty string. If the result is an empty string then it will be eitherATTRIBUTE_NOT_DEFINED
if the attribute wasn't specified orATTRIBUTE_VALUE_EMPTY
if the attribute was specified but it was empty.- Specified by:
getAttribute
in interfaceElement
- Parameters:
attributeName
- the name of the attribute- Returns:
- the value of the attribute or
ATTRIBUTE_NOT_DEFINED
orATTRIBUTE_VALUE_EMPTY
-
getAttributeDirect
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
orATTRIBUTE_VALUE_EMPTY
-
removeAttribute
Removes an attribute specified by name from this element.- Specified by:
removeAttribute
in interfaceElement
- Parameters:
attributeName
- the attribute attributeName
-
removeAttributeNS
Removes an attribute specified by namespace and local name from this element.- Specified by:
removeAttributeNS
in interfaceElement
- Parameters:
namespaceURI
- the URI that identifies an XML namespacelocalName
- the name within the namespace
-
removeAttributeNode
Not yet implemented.- Specified by:
removeAttributeNode
in interfaceElement
-
hasAttributeNS
Returns whether the attribute specified by namespace and local name has a value.- Specified by:
hasAttributeNS
in interfaceElement
- Parameters:
namespaceURI
- the URI that identifies an XML namespacelocalName
- 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
Returns the map holding the attributes, keyed by name.- Returns:
- the attributes map
-
getAttributes
- Specified by:
getAttributes
in interfaceNode
- Overrides:
getAttributes
in classDomNode
-
setAttribute
Sets the value of the attribute specified by name.- Specified by:
setAttribute
in interfaceElement
- Parameters:
attributeName
- the name of the attributeattributeValue
- the value of the attribute
-
setAttributeNS
Sets the value of the attribute specified by namespace and qualified name.- Specified by:
setAttributeNS
in interfaceElement
- Parameters:
namespaceURI
- the URI that identifies an XML namespacequalifiedName
- the qualified name (prefix:local) of the attributeattributeValue
- the value of the attribute
-
setAttributeNS
protected void setAttributeNS(String namespaceURI, String qualifiedName, 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 namespacequalifiedName
- the qualified name (prefix:local) of the attributeattributeValue
- the value of the attributenotifyAttributeChangeListeners
- to notify the associatedHtmlAttributeChangeListener
snotifyMutationObservers
- to notifyMutationObserver
s or not
-
isAttributeCaseSensitive
protected boolean isAttributeCaseSensitive()Indicates if the attribute names are case sensitive.- Returns:
true
-
getAttributeNS
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 eitherATTRIBUTE_NOT_DEFINED
if the attribute wasn't specified orATTRIBUTE_VALUE_EMPTY
if the attribute was specified but it was empty.- Specified by:
getAttributeNS
in interfaceElement
- Parameters:
namespaceURI
- the URI that identifies an XML namespacelocalName
- the name within the namespace- Returns:
- the value of the attribute or
ATTRIBUTE_NOT_DEFINED
orATTRIBUTE_VALUE_EMPTY
-
getAttributeNode
- Specified by:
getAttributeNode
in interfaceElement
-
getAttributeNodeNS
- Specified by:
getAttributeNodeNS
in interfaceElement
-
writeStyleToElement
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Parameters:
styleMap
- the styles
-
getElementsByTagName
- Specified by:
getElementsByTagName
in interfaceElement
-
getStaticElementsByTagName
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Type Parameters:
E
- the specific HtmlElement type- Parameters:
tagName
- The name of the tag to match on- Returns:
- A list of matching elements; this is not a live list
-
getElementsByTagNameNS
Not yet implemented.- Specified by:
getElementsByTagNameNS
in interfaceElement
-
getSchemaTypeInfo
Not yet implemented.- Specified by:
getSchemaTypeInfo
in interfaceElement
-
setIdAttribute
Not yet implemented.- Specified by:
setIdAttribute
in interfaceElement
-
setIdAttributeNS
Not yet implemented.- Specified by:
setIdAttributeNS
in interfaceElement
-
setAttributeNode
- Specified by:
setAttributeNode
in interfaceElement
-
setAttributeNodeNS
Not yet implemented.- Specified by:
setAttributeNodeNS
in interfaceElement
-
setIdAttributeNode
Not yet implemented.- Specified by:
setIdAttributeNode
in interfaceElement
-
cloneNode
-
getId
- Returns:
- the identifier of this element
-
setId
Sets the identifier this element.- Parameters:
newId
- the new identifier of this element
-
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
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
- Returns:
- an Iterable over the DomElement children of this object, i.e. excluding the non-element nodes
-
toString
Returns a string representation of this element. -
click
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:
IOException
- if an IO error occurs
-
click
public <P extends Page> P click(boolean shiftKey, boolean ctrlKey, boolean altKey) throws 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 clickctrlKey
-true
if CTRL is pressed during the clickaltKey
-true
if ALT is pressed during the click- Returns:
- the page contained in the current window as returned by
WebClient.getCurrentWindow()
- Throws:
IOException
- if an IO error occurs
-
click
public <P extends Page> P click(boolean shiftKey, boolean ctrlKey, boolean altKey, boolean triggerMouseEvents) throws 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 clickctrlKey
-true
if CTRL is pressed during the clickaltKey
-true
if ALT is pressed during the clicktriggerMouseEvents
- if true trigger the mouse events also- Returns:
- the page contained in the current window as returned by
WebClient.getCurrentWindow()
- Throws:
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 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 clickctrlKey
-true
if CTRL is pressed during the clickaltKey
-true
if ALT is pressed during the clicktriggerMouseEvents
- if true trigger the mouse events alsohandleFocus
- if true set the focus (and trigger the event)ignoreVisibility
- whether to ignore visibility or notdisableProcessLabelAfterBubbling
- ignore label processing- Returns:
- the page contained in the current window as returned by
WebClient.getCurrentWindow()
- Throws:
IOException
- if an IO error occurs
-
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 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 usedshiftKey
-true
if SHIFT is pressed during the clickctrlKey
-true
if CTRL is pressed during the clickaltKey
-true
if ALT is pressed during the clickignoreVisibility
- whether to ignore visibility or not- Returns:
- the page contained in the current window as returned by
WebClient.getCurrentWindow()
- Throws:
IOException
- if an IO error occurs
-
doClickStateUpdate
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 pressedctrlKey
-true
if CTRL is pressed- Returns:
- true if doClickFireEvent method has to be called later on (to signal, that the value was changed)
- Throws:
IOException
- if an IO error occurs
-
propagateClickStateUpdateToParent
protected boolean propagateClickStateUpdateToParent()- Returns:
- true or false
- See Also:
-
doClickFireChangeEvent
protected void doClickFireChangeEvent()This method implements the control onchange handler call during the click action. -
doClickFireClickEvent
This method implements the control onclick handler call during the click action.- Parameters:
event
- the click event used- Returns:
- the script result
-
dblClick
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 thatclick()
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:
IOException
- if an IO error occurs
-
dblClick
public <P extends Page> P dblClick(boolean shiftKey, boolean ctrlKey, boolean altKey) throws 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 thatclick(boolean, boolean, boolean)
is automatically called first.- Type Parameters:
P
- the page type- Parameters:
shiftKey
-true
if SHIFT is pressed during the double-clickctrlKey
-true
if CTRL is pressed during the double-clickaltKey
-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:
IOException
- if an IO error occurs
-
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
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 movectrlKey
-true
if CTRL is pressed during the mouse movealtKey
-true
if ALT is pressed during the mouse movebutton
- the button code, must beMouseEvent.BUTTON_LEFT
,MouseEvent.BUTTON_MIDDLE
orMouseEvent.BUTTON_RIGHT
- Returns:
- the page which this element's window contains after the mouse move
-
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
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 movectrlKey
-true
if CTRL is pressed during the mouse movealtKey
-true
if ALT is pressed during the mouse movebutton
- the button code, must beMouseEvent.BUTTON_LEFT
,MouseEvent.BUTTON_MIDDLE
orMouseEvent.BUTTON_RIGHT
- Returns:
- the page which this element's window contains after the mouse move
-
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
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 movectrlKey
-true
if CTRL is pressed during the mouse movealtKey
-true
if ALT is pressed during the mouse movebutton
- the button code, must beMouseEvent.BUTTON_LEFT
,MouseEvent.BUTTON_MIDDLE
orMouseEvent.BUTTON_RIGHT
- Returns:
- the page which this element's window contains after the mouse move
-
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
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 clickctrlKey
-true
if CTRL is pressed during the mouse clickaltKey
-true
if ALT is pressed during the mouse clickbutton
- the button code, must beMouseEvent.BUTTON_LEFT
,MouseEvent.BUTTON_MIDDLE
orMouseEvent.BUTTON_RIGHT
- Returns:
- the page which this element's window contains after the mouse click
-
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
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 releasectrlKey
-true
if CTRL is pressed during the mouse click releasealtKey
-true
if ALT is pressed during the mouse click releasebutton
- the button code, must beMouseEvent.BUTTON_LEFT
,MouseEvent.BUTTON_MIDDLE
orMouseEvent.BUTTON_RIGHT
- Returns:
- the page which this element's window contains after the mouse click release
-
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
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 clickctrlKey
-true
if CTRL is pressed during the mouse clickaltKey
-true
if ALT is pressed during the mouse click- Returns:
- the page which this element's window contains after the mouse click
-
fireEvent
- Parameters:
eventType
- the event type (like "load", "click")- Returns:
- the execution result, or
null
if nothing is executed
-
fireEvent
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 bypreventDefault()
.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()Returnstrue
if state updates should be done before onclick event handling. This method returnsfalse
by default, and is expected to be overridden to returntrue
by derived classes likeHtmlCheckBoxInput
.- 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
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
- Specified by:
setNodeValue
in interfaceNode
-
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
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:
SAXException
- in case of errorIOException
- in case of error
-