public class HtmlPage extends SgmlPage
This class provides different methods to access the page's content like
getForms()
, getAnchors()
, getElementById(String)
, ... as well as the
very powerful inherited methods DomNode.getByXPath(String)
and DomNode.getFirstByXPath(String)
for fine grained user specific access to child nodes.
Child elements allowing user interaction provide methods for this purpose like DomElement.click()
,
HtmlElement.type(String)
, HtmlOption.setSelected(boolean)
, ...
HtmlPage instances should not be instantiated directly. They will be returned by WebClient.getPage(String)
when the content type of the server's response is text/html
(or one of its variations).
Example:
final HtmlPage page = webClient.
getPage
("http://mywebsite/some/page.html");
DomNode.ChildIterator, DomNode.DescendantDomElementsIterator, DomNode.DescendantDomNodesIterator, DomNode.DescendantElementsIterator<T extends DomNode>, DomNode.DescendantHtmlElementsIterator
PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED
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 and Description |
---|
HtmlPage(WebResponse webResponse,
WebWindow webWindow)
Creates an instance of HtmlPage.
|
Modifier and Type | Method and Description |
---|---|
void |
addAutoCloseable(AutoCloseable autoCloseable)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
addHtmlAttributeChangeListener(HtmlAttributeChangeListener listener)
Adds an HtmlAttributeChangeListener to the listener list.
|
Node |
adoptNode(Node source)
Not yet implemented.
|
protected void |
checkChildHierarchy(Node newChild)
Check for insertion errors for a new child node.
|
void |
cleanUp()
Clean up this page.
|
void |
clearComputedStyles()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
clearComputedStyles(DomElement element)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
clearComputedStylesUpToRoot(DomElement element)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
protected HtmlPage |
clone()
Creates a clone of this instance, and clears cached state to be not shared with the original.
|
HtmlPage |
cloneNode(boolean deep) |
Attr |
createAttributeNS(String namespaceURI,
String qualifiedName)
Not yet implemented.
|
DomElement |
createElement(String tagName) |
DomElement |
createElementNS(String namespaceURI,
String qualifiedName) |
EntityReference |
createEntityReference(String id)
Not yet implemented.
|
ProcessingInstruction |
createProcessingInstruction(String namespaceURI,
String qualifiedName)
Not yet implemented.
|
void |
deregisterFramesIfNeeded()
Deregister frames that are no longer in use.
|
ScriptResult |
executeJavaScript(String sourceCode)
Executes the specified JavaScript code within the page.
|
ScriptResult |
executeJavaScript(String sourceCode,
String sourceName,
int startLine)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
ScriptResult |
executeJavaScriptFunction(Object function,
Object thisObject,
Object[] args,
DomNode htmlElementScope)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
HtmlElement |
getActiveElement()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
HtmlAnchor |
getAnchorByHref(String href)
Returns the
HtmlAnchor with the specified href. |
HtmlAnchor |
getAnchorByName(String name)
Returns the
HtmlAnchor with the specified name. |
HtmlAnchor |
getAnchorByText(String text)
Returns the first anchor with the specified text.
|
List<HtmlAnchor> |
getAnchors()
Returns a list of all anchors contained in this page.
|
URL |
getBaseURL()
The base URL used to resolve relative URLs.
|
HtmlBody |
getBody() |
Charset |
getCharset()
Returns the encoding.
|
String |
getContentType()
Returns the content type of this page.
|
HtmlElement |
getDocumentElement()
Returns the document element.
|
String |
getDocumentURI()
Not yet implemented.
|
HTMLParserDOMBuilder |
getDOMBuilder()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
DOMConfiguration |
getDomConfig()
Not yet implemented.
|
DomElement |
getElementById(String elementId) |
<E extends DomElement> |
getElementByName(String name)
Returns the element with the specified name.
|
HtmlElement |
getElementFromPoint(int x,
int y)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
List<DomElement> |
getElementsById(String elementId)
Returns the elements with the specified ID.
|
List<DomElement> |
getElementsByIdAndOrName(String idAndOrName)
Returns the elements with the specified string for their name or ID.
|
List<DomElement> |
getElementsByName(String name)
Returns the elements with the specified name attribute.
|
DomElement |
getFocusedElement()
Returns the element with the focus or null if no element has the focus.
|
HtmlForm |
getFormByName(String name)
Returns the first form that matches the specified name.
|
List<HtmlForm> |
getForms()
Returns a list of all the forms in this page.
|
FrameWindow |
getFrameByName(String name)
Returns the first frame contained in this page with the specified name.
|
List<FrameWindow> |
getFrames()
Returns a list containing all the frames (from frame and iframe tags) in this page
in document order.
|
URL |
getFullyQualifiedUrl(String relativeUrl)
Given a relative URL (ie
/foo ), returns a fully-qualified URL based on
the URL that was used to load this page. |
HtmlElement |
getHead()
Returns the head element.
|
HtmlElement |
getHtmlElementByAccessKey(char accessKey)
Returns the HTML element that is assigned to the specified access key.
|
<E extends HtmlElement> |
getHtmlElementById(String elementId)
Returns the HTML element with the specified ID.
|
List<HtmlElement> |
getHtmlElementsByAccessKey(char accessKey)
Returns all the HTML elements that are assigned to the specified access key.
|
DOMImplementation |
getImplementation()
Not yet implemented.
|
String |
getInputEncoding()
Not yet implemented.
|
protected List<HtmlMeta> |
getMetaTags(String httpEquiv)
Gets the meta tag for a given
http-equiv value. |
Map<String,String> |
getNamespaces()
Returns all namespaces defined in the root element of this page.
|
Document |
getOwnerDocument() |
HtmlPage |
getPage()
Returns the page that contains this node.
|
String |
getResolvedTarget(String elementTarget)
Given a target attribute value, resolve the target using a base target for the page.
|
List<SimpleRange> |
getSelectionRanges()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
boolean |
getStrictErrorChecking()
Not yet implemented.
|
ComputedCssStyleDeclaration |
getStyleFromCache(DomElement element,
String normalizedPseudo)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
List<CssStyleSheet> |
getStyleSheets()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
List<String> |
getTabbableElementIds()
Returns a list of ids (strings) that correspond to the tabbable elements
in this page.
|
List<HtmlElement> |
getTabbableElements()
Returns a list of all elements that are tabbable in the order that will
be used for tabbing.
|
String |
getTitleText()
Returns the title of this page or an empty string if the title wasn't specified.
|
String |
getXmlEncoding() |
boolean |
getXmlStandalone() |
String |
getXmlVersion() |
boolean |
handles(Event event)
Indicates if the provided event can be applied to this node.
|
boolean |
hasCaseSensitiveTagNames()
Returns
true if this page has case-sensitive tag names, false otherwise. |
Node |
importNode(Node importedNode,
boolean deep)
Not yet implemented.
|
void |
initialize()
Initialize this page.
|
boolean |
isAttachedToPage()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
boolean |
isBeingParsed()
Returns
true if an HTML parser is operating on this page, adding content to it. |
boolean |
isHtmlPage()
Returns true if this page is an HtmlPage.
|
boolean |
isOnbeforeunloadAccepted()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
boolean |
isParsingHtmlSnippet()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
boolean |
isParsingInlineHtmlSnippet()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
boolean |
isQuirksMode()
Returns whether the current page mode is in
quirks mode or in standards mode . |
DomElement |
pressAccessKey(char accessKey)
Simulate pressing an access key.
|
void |
putStyleIntoCache(DomElement element,
String normalizedPseudo,
ComputedCssStyleDeclaration style)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
Page |
refresh()
Refreshes the page by sending the same parameters as previously sent to get this page.
|
void |
registerInlineSnippetParsingEnd()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
registerInlineSnippetParsingStart()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
registerParsingEnd()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
registerParsingStart()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
registerSnippetParsingEnd()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
registerSnippetParsingStart()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
removeHtmlAttributeChangeListener(HtmlAttributeChangeListener listener)
Removes an HtmlAttributeChangeListener from the listener list.
|
Node |
renameNode(Node newNode,
String namespaceURI,
String qualifiedName)
Not yet implemented.
|
void |
save(File file)
Saves the current page, with all images, to the specified location.
|
void |
setDocumentType(DocumentType type)
Sets the document type.
|
void |
setDocumentURI(String documentURI)
Not yet implemented.
|
void |
setDOMBuilder(HTMLParserDOMBuilder htmlUnitDOMBuilder)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
setElementFromPointHandler(ElementFromPointHandler elementFromPointHandler)
Sets the
ElementFromPointHandler . |
void |
setElementWithFocus(DomElement elementWithFocus)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
boolean |
setFocusedElement(DomElement newElement)
Moves the focus to the specified element.
|
boolean |
setFocusedElement(DomElement newElement,
boolean windowActivated)
Moves the focus to the specified element.
|
void |
setNodeValue(String value) |
void |
setPrefix(String prefix) |
void |
setSelectionRange(SimpleRange selectionRange)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
void |
setStrictErrorChecking(boolean strictErrorChecking)
Not yet implemented.
|
void |
setTitleText(String message)
Sets the text for the title of this page.
|
void |
setXmlStandalone(boolean xmlStandalone)
Not yet implemented.
|
void |
setXmlVersion(String xmlVersion)
Not yet implemented.
|
HtmlElement |
tabToNextElement()
Move the focus to the next element in the tab order.
|
HtmlElement |
tabToPreviousElement()
Move the focus to the previous element in the tab order.
|
String |
toString()
Gives a basic representation for debugging purposes.
|
void |
writeInParsedStream(String string)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
asXml, characterDataChangeListenerAdded, createAttribute, createCDATASection, createComment, createDocumentFragment, createNodeIterator, createTextNode, domChangeListenerAdded, getCanonicalXPath, getDoctype, getElementsByTagName, getElementsByTagNameNS, getEnclosingWindow, getNodeName, getNodeType, getUrl, getWebClient, getWebResponse, isCharacterDataChangeListenerInUse, isDomChangeListenerInUse, isPrinting, normalizeDocument, setEnclosingWindow, setPrinting
addCharacterDataChangeListener, addDomChangeListener, appendChild, asNormalizedText, basicRemove, closest, compareDocumentPosition, detach, fireCharacterDataChanged, fireNodeAdded, fireNodeDeleted, getAncestors, getAttributes, getBaseURI, getByXPath, getByXPath, getChildNodes, getChildren, getDescendants, getDomElementDescendants, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstByXPath, getFirstChild, getHtmlElementDescendants, getHtmlPageOrNull, getIndex, getLastChild, getLocalName, getNamespaceURI, getNextElementSibling, getNextSibling, getNodeValue, getParentNode, getPrefix, getPreviousElementSibling, getPreviousSibling, getReadyState, getScriptableObject, getSelectorList, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, getVisibleText, hasAttributes, hasChildNodes, hasFeature, insertBefore, insertBefore, isAncestorOf, isAncestorOfAny, isDefaultNamespace, isDisplayed, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, mayBeDisplayed, normalize, notifyIncorrectness, onAddedToDocumentFragment, onAddedToPage, onAllChildrenAddedToPage, parseHtmlSnippet, printChildrenAsXml, printXml, processImportNode, querySelector, querySelectorAll, quietlyRemoveAndMoveChildrenTo, remove, removeAllChildren, removeCharacterDataChangeListener, removeChild, removeDomChangeListener, replace, replaceChild, setEndLocation, setParentNode, setReadyState, setScriptableObject, setStartLocation, setTextContent, setUserData
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
appendChild, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setTextContent, setUserData
public HtmlPage(WebResponse webResponse, WebWindow webWindow)
WebClient.getPage(String)
.webResponse
- the web response that was used to create this pagewebWindow
- the window that this page is being loaded intopublic HtmlPage getPage()
public boolean hasCaseSensitiveTagNames()
true
if this page has case-sensitive tag names, false
otherwise. In general,
XML has case-sensitive tag names, and HTML doesn't. This is especially important during XPath matching.hasCaseSensitiveTagNames
in class SgmlPage
true
if this page has case-sensitive tag names, false
otherwisepublic void initialize() throws IOException, FailingHttpStatusCodeException
IOException
- if an IO problem occursFailingHttpStatusCodeException
- if the server returns a failing status code AND the property
WebClientOptions.setThrowExceptionOnFailingStatusCode(boolean)
is set
to true.public void cleanUp()
public HtmlElement getDocumentElement()
getDocumentElement
in interface Document
getDocumentElement
in class SgmlPage
public HtmlBody getBody()
body
element, or null
if it does not yet existpublic HtmlElement getHead()
public Document getOwnerDocument()
getOwnerDocument
in interface Node
getOwnerDocument
in class DomNode
public String getInputEncoding()
public String getXmlEncoding()
public boolean getXmlStandalone()
public void setXmlStandalone(boolean xmlStandalone) throws DOMException
DOMException
public String getXmlVersion()
public void setXmlVersion(String xmlVersion) throws DOMException
DOMException
public boolean getStrictErrorChecking()
public void setStrictErrorChecking(boolean strictErrorChecking)
public String getDocumentURI()
public void setDocumentURI(String documentURI)
public Node adoptNode(Node source) throws DOMException
DOMException
public DOMConfiguration getDomConfig()
public Node renameNode(Node newNode, String namespaceURI, String qualifiedName) throws DOMException
DOMException
public Charset getCharset()
getCharset
in class SgmlPage
public String getContentType()
getContentType
in class SgmlPage
public DOMImplementation getImplementation()
public DomElement createElement(String tagName)
tagName
- the tag name, preferably in lowercasepublic DomElement createElementNS(String namespaceURI, String qualifiedName)
public Attr createAttributeNS(String namespaceURI, String qualifiedName)
public EntityReference createEntityReference(String id)
public ProcessingInstruction createProcessingInstruction(String namespaceURI, String qualifiedName)
public DomElement getElementById(String elementId)
public HtmlAnchor getAnchorByName(String name) throws ElementNotFoundException
HtmlAnchor
with the specified name.name
- the name to search byHtmlAnchor
with the specified nameElementNotFoundException
- if the anchor could not be foundpublic HtmlAnchor getAnchorByHref(String href) throws ElementNotFoundException
HtmlAnchor
with the specified href.href
- the string to search byElementNotFoundException
- if the anchor could not be foundpublic List<HtmlAnchor> getAnchors()
HtmlAnchor
in this pagepublic HtmlAnchor getAnchorByText(String text) throws ElementNotFoundException
text
- the text to search forElementNotFoundException
- if no anchors are found with the specified textpublic HtmlForm getFormByName(String name) throws ElementNotFoundException
name
- the name to search forElementNotFoundException
- If no forms match the specified result.public List<HtmlForm> getForms()
public URL getFullyQualifiedUrl(String relativeUrl) throws MalformedURLException
/foo
), returns a fully-qualified URL based on
the URL that was used to load this page.relativeUrl
- the relative URLMalformedURLException
- if an error occurred when creating a URL objectpublic String getResolvedTarget(String elementTarget)
elementTarget
- the target specified as an attribute of the elementpublic List<String> getTabbableElementIds()
getTabbableElements()
public List<HtmlElement> getTabbableElements()
The rules for determining tab order are as follows:
The following elements support the tabindex
attribute: A, AREA, BUTTON,
INPUT, OBJECT, SELECT, and TEXTAREA.
public HtmlElement getHtmlElementByAccessKey(char accessKey)
Only the following HTML elements may have accesskey
s defined: A, AREA,
BUTTON, INPUT, LABEL, LEGEND, and TEXTAREA.
accessKey
- the key to look forpublic List<HtmlElement> getHtmlElementsByAccessKey(char accessKey)
The HTML specification seems to indicate that one accesskey cannot be used for multiple elements however Internet Explorer does seem to support this. It's worth noting that Firefox does not support multiple elements with one access key so you are making your HTML browser specific if you rely on this feature.
Only the following HTML elements may have accesskey
s defined: A, AREA,
BUTTON, INPUT, LABEL, LEGEND, and TEXTAREA.
accessKey
- the key to look forpublic ScriptResult executeJavaScript(String sourceCode)
Executes the specified JavaScript code within the page. The usage would be similar to what can be achieved to execute JavaScript in the current page by entering "javascript:...some JS code..." in the URL field of a native browser.
Note: the provided code won't be executed if JavaScript has been disabled on the WebClient
(see WebClient.isJavaScriptEnabled()
.
sourceCode
- the JavaScript code to executepublic ScriptResult executeJavaScript(String sourceCode, String sourceName, int startLine)
Execute the specified JavaScript if a JavaScript engine was successfully instantiated. If this JavaScript causes the current page to be reloaded (through location="" or form.submit()) then return the new page. Otherwise return the current page.
Please note: Although this method is public, it is not intended for general execution of JavaScript. Users of HtmlUnit should interact with the pages as a user would by clicking on buttons or links and having the JavaScript event handlers execute as needed..
sourceCode
- the JavaScript code to executesourceName
- the name for this chunk of code (will be displayed in error messages)startLine
- the line at which the script source startspublic String getTitleText()
public void setTitleText(String message)
message
- the new textpublic boolean isOnbeforeunloadAccepted()
public void deregisterFramesIfNeeded()
public List<FrameWindow> getFrames()
FrameWindow
public FrameWindow getFrameByName(String name) throws ElementNotFoundException
name
- the name to search forElementNotFoundException
- If no frame exist in this page with the specified name.public DomElement pressAccessKey(char accessKey) throws IOException
accessKey
- the key that will be pressedIOException
- if an IO error occurs during the processing of this access key (this
would only happen if the access key triggered a button which in turn caused a page load)public HtmlElement tabToNextElement()
getTabbableElements()
public HtmlElement tabToPreviousElement()
getTabbableElements()
public <E extends HtmlElement> E getHtmlElementById(String elementId) throws ElementNotFoundException
E
- the element typeelementId
- the ID value to search forElementNotFoundException
- if no element was found matching the specified IDpublic List<DomElement> getElementsById(String elementId)
elementId
- the ID value to search forpublic <E extends DomElement> E getElementByName(String name) throws ElementNotFoundException
E
- the element typename
- the name value to search forElementNotFoundException
- if no element was found matching the specified namepublic List<DomElement> getElementsByName(String name)
name
- the name value to search forpublic List<DomElement> getElementsByIdAndOrName(String idAndOrName)
idAndOrName
- the value to search forpublic String toString()
protected List<HtmlMeta> getMetaTags(String httpEquiv)
http-equiv
value.httpEquiv
- the http-equiv
valueHtmlMeta
protected HtmlPage clone()
public HtmlPage cloneNode(boolean deep)
public void addHtmlAttributeChangeListener(HtmlAttributeChangeListener listener)
listener
- the attribute change listener to be addedremoveHtmlAttributeChangeListener(HtmlAttributeChangeListener)
public void removeHtmlAttributeChangeListener(HtmlAttributeChangeListener listener)
listener
- the attribute change listener to be removedaddHtmlAttributeChangeListener(HtmlAttributeChangeListener)
protected void checkChildHierarchy(Node newChild) throws DOMException
checkChildHierarchy
in class DomNode
newChild
- the new child node that is being inserted below this nodeDOMException
- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
not allow children of the type of the newChild node, or if the node to insert is one of
this node's ancestors or this node itself, or if this node is of type Document and the
DOM application attempts to insert a second DocumentType or Element node.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the
one that created this node.public boolean isBeingParsed()
true
if an HTML parser is operating on this page, adding content to it.true
if an HTML parser is operating on this page, adding content to itpublic void registerParsingStart()
public void registerParsingEnd()
public boolean isParsingHtmlSnippet()
true
if an HTML parser is parsing a non-inline HTML snippet to add content
to this page. Non-inline content is content that is parsed for the page, but not in the
same stream as the page itself -- basically anything other than document.write()
or document.writeln()
: innerHTML
, outerHTML
,
document.createElement()
, etc.true
if an HTML parser is parsing a non-inline HTML snippet to add content
to this pagepublic void registerSnippetParsingStart()
public void registerSnippetParsingEnd()
public boolean isParsingInlineHtmlSnippet()
true
if an HTML parser is parsing an inline HTML snippet to add content
to this page. Inline content is content inserted into the parser stream dynamically
while the page is being parsed (i.e. document.write()
or document.writeln()
).true
if an HTML parser is parsing an inline HTML snippet to add content
to this pagepublic void registerInlineSnippetParsingStart()
public void registerInlineSnippetParsingEnd()
public Page refresh() throws IOException
IOException
- if an IO problem occurspublic void writeInParsedStream(String string)
Parses the given string as would it belong to the content being parsed at the current parsing position
string
- the HTML code to write in placepublic void setDOMBuilder(HTMLParserDOMBuilder htmlUnitDOMBuilder)
htmlUnitDOMBuilder
- the builderpublic HTMLParserDOMBuilder getDOMBuilder()
public Map<String,String> getNamespaces()
Returns all namespaces defined in the root element of this page.
The default namespace has a key of an empty string.
public void setDocumentType(DocumentType type)
setDocumentType
in class SgmlPage
type
- the document typepublic void save(File file) throws IOException
file
- file to write this page intoIOException
- If an error occurspublic boolean isQuirksMode()
quirks mode
or in standards mode
.quirks mode
, false for standards mode
public boolean isAttachedToPage()
isAttachedToPage
in class DomNode
true
if the page is one ancestor of the node.public boolean isHtmlPage()
isHtmlPage
in interface Page
isHtmlPage
in class SgmlPage
public URL getBaseURL()
public void addAutoCloseable(AutoCloseable autoCloseable)
AutoCloseable
, which would be closed during the cleanUp()
.autoCloseable
- the autoclosablepublic boolean handles(Event event)
public void setElementFromPointHandler(ElementFromPointHandler elementFromPointHandler)
ElementFromPointHandler
.elementFromPointHandler
- the handlerpublic HtmlElement getElementFromPoint(int x, int y)
x
- the x offset, in pixelsy
- the y offset, in pixelspublic boolean setFocusedElement(DomElement newElement)
newElement
- the element that will receive the focus, use null
to remove focus from any elementgetFocusedElement()
public boolean setFocusedElement(DomElement newElement, boolean windowActivated)
newElement
- the element that will receive the focus, use null
to remove focus from any elementwindowActivated
- - whether the enclosing window got focus resulting in specified element getting focusgetFocusedElement()
public DomElement getFocusedElement()
setFocusedElement(DomElement)
public void setElementWithFocus(DomElement elementWithFocus)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the element with focus.elementWithFocus
- the element with focuspublic HtmlElement getActiveElement()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
public List<SimpleRange> getSelectionRanges()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Returns the page's current selection ranges.
public void setSelectionRange(SimpleRange selectionRange)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Makes the specified selection range the *only* selection range on this page.
selectionRange
- the selection rangepublic ScriptResult executeJavaScriptFunction(Object function, Object thisObject, Object[] args, DomNode htmlElementScope)
function
- the JavaScript Function to callthisObject
- the "this" object to be used during invocationargs
- the arguments to pass into the callhtmlElementScope
- the HTML element for which this script is being executed
This element will be the context during the JavaScript execution. If null,
the context will default to the page.public void setNodeValue(String value)
public void setPrefix(String prefix)
public void clearComputedStyles()
clearComputedStyles
in class SgmlPage
public void clearComputedStyles(DomElement element)
Element
.clearComputedStyles
in class SgmlPage
element
- the element to clear its cachepublic void clearComputedStylesUpToRoot(DomElement element)
Element
and all parent elements.clearComputedStylesUpToRoot
in class SgmlPage
element
- the element to clear its cachepublic ComputedCssStyleDeclaration getStyleFromCache(DomElement element, String normalizedPseudo)
element
- the element to clear its cachenormalizedPseudo
- the pseudo attributepublic void putStyleIntoCache(DomElement element, String normalizedPseudo, ComputedCssStyleDeclaration style)
element
- the element to clear its cachenormalizedPseudo
- the pseudo attributestyle
- the CSS2Properties to cachepublic List<CssStyleSheet> getStyleSheets()
Copyright © 2002–2024 Gargoyle Software Inc.. All rights reserved.