DomElement surge_url = tempPage.getElementById("surge_url"); if (surge_url != null) { String href = surge_url.getAttribute("href"); System.out.println(href);
/** * Detaches this attribute from the parent HTML element after caching the attribute value. */ public void detachFromParent() { if (parent_ != null) { value_ = parent_.getAttribute(name_); } parent_ = null; }
/** * Returns the value of this attribute. * @return the value of this attribute */ public String jsxGet_value() { if (parent_ != null) { return parent_.getAttribute(name_); } return value_; }
/** * Returns the value of this attribute. * @return the value of this attribute */ public String jsxGet_value() { if (parent_ != null) { return parent_.getAttribute(name_); } return value_; }
/** * Detaches this attribute from the parent HTML element after caching the attribute value. */ public void detachFromParent() { if (parent_ != null) { value_ = parent_.getAttribute(name_); } parent_ = null; }
/** * Detaches this attribute from the parent HTML element after caching the attribute value. */ public void detachFromParent() { if (parent_ != null) { value_ = parent_.getAttribute(name_); } parent_ = null; }
/** * Returns the value of this attribute. * @return the value of this attribute */ public String jsxGet_value() { if (parent_ != null) { return parent_.getAttribute(name_); } return value_; }
DomNodeList<DomElement> images = result.getElementsByTagName("img"); for (DomElement e : images) { e.setAttribute("src", result.getFullyQualifiedUrl(e.getAttribute("src")).toString()); }
/** * Recursively checks whether "xml:space" attribute is set to "default". * @param node node to start checking from * @return {@link Boolean#TRUE} if "default" is set, {@link Boolean#FALSE} for other value, * or null if nothing is set. */ private static Boolean isXMLSpaceDefault(DomNode node) { for ( ; node instanceof DomElement; node = node.getParentNode()) { final String value = ((DomElement) node).getAttribute("xml:space"); if (!value.isEmpty()) { return "default".equals(value); } } return null; }
/** * 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 {@link #ATTRIBUTE_NOT_DEFINED} * if the attribute wasn't specified or {@link #ATTRIBUTE_VALUE_EMPTY} if the * attribute was specified but it was empty. * * @param namespaceURI the URI that identifies an XML namespace * @param localName the name within the namespace * @return the value of the attribute or {@link #ATTRIBUTE_NOT_DEFINED} or {@link #ATTRIBUTE_VALUE_EMPTY} */ public final String getAttributeNS(final String namespaceURI, final String localName) { final String qualifiedName = getQualifiedName(namespaceURI, localName); if (qualifiedName != null) { return getAttribute(qualifiedName); } return ATTRIBUTE_NOT_DEFINED; }
/** * Recursively checks whether "xml:space" attribute is set to "default". * @param node node to start checking from * @return {@link Boolean#TRUE} if "default" is set, {@link Boolean#FALSE} for other value, * or null if nothing is set. */ private static Boolean isXMLSpaceDefault(DomNode node) { for ( ; node instanceof DomElement; node = node.getParentNode()) { final String value = ((DomElement) node).getAttribute("xml:space"); if (!value.isEmpty()) { return "default".equals(value); } } return null; }
public String getAttribute(String name) { if ("value".equals(name) && element instanceof HtmlOption) { // for options, we want text if no value was specified return ((HtmlOption) element).getValueAttribute(); } else { if (!element.hasAttribute(name)) return null; return element.getAttribute(name); } }
@Override public List<WebElement> findElementsByLinkText(String linkText) { assertElementNotStale(); String expectedText = linkText.trim(); List<? extends HtmlElement> htmlElements = ((HtmlElement) element).getHtmlElementsByTagName("a"); List<WebElement> webElements = new ArrayList<>(); for (DomElement e : htmlElements) { if (expectedText.equals(e.getTextContent().trim()) && e.getAttribute("href") != null) { webElements.add(getParent().newHtmlUnitWebElement(e)); } } return webElements; }
/** * Returns the value of the specified attribute. * @param attributeName attribute name * @param flags IE-specific flags (see the MSDN documentation for more info) * @return the value of the specified attribute, {@code null} if the attribute is not defined * @see <a href="http://msdn.microsoft.com/en-us/library/ms536429.aspx">MSDN Documentation</a> * @see <a href="http://reference.sitepoint.com/javascript/Element/getAttribute">IE Bug Documentation</a> */ @JsxFunction public String getAttribute(final String attributeName, final Integer flags) { String value = getDomNodeOrDie().getAttribute(attributeName); if (value == ATTRIBUTE_NOT_DEFINED) { value = null; } return value; }
/** * Search for the namespace URI of the given prefix, starting from the specified element. * @param element the element to start searching from * @param prefix the namespace prefix * @return the namespace URI bound to the prefix; or null if there is no such namespace */ public static String lookupNamespaceURI(final DomElement element, final String prefix) { String uri = element.getAttribute("xmlns:" + prefix); if (uri == DomElement.ATTRIBUTE_NOT_DEFINED) { final DomNode parentNode = element.getParentNode(); if (parentNode instanceof DomElement) { uri = lookupNamespaceURI((DomElement) parentNode, prefix); } } return uri; }
/** * Search for the namespace URI of the given prefix, starting from the specified element. * @param element the element to start searching from * @param prefix the namespace prefix * @return the namespace URI bound to the prefix; or null if there is no such namespace */ public static String lookupNamespaceURI(final DomElement element, final String prefix) { String uri = element.getAttribute("xmlns:" + prefix); if (uri == DomElement.ATTRIBUTE_NOT_DEFINED) { final DomNode parentNode = element.getParentNode(); if (parentNode instanceof DomElement) { uri = lookupNamespaceURI((DomElement) parentNode, prefix); } } return uri; }
/** * Detaches this attribute from the parent HTML element after caching the attribute value. */ public void detachFromParent() { final DomAttr domNode = getDomNodeOrDie(); final DomElement parent = (DomElement) domNode.getParentNode(); if (parent != null) { domNode.setValue(parent.getAttribute(getName())); } domNode.remove(); }
/** * Detaches this attribute from the parent HTML element after caching the attribute value. */ public void detachFromParent() { final DomAttr domNode = getDomNodeOrDie(); final DomElement parent = (DomElement) domNode.getParentNode(); if (parent != null) { domNode.setValue(parent.getAttribute(getName())); } domNode.remove(); }
/** * Detaches this attribute from the parent HTML element after caching the attribute value. */ public void detachFromParent() { final DomAttr domNode = getDomNodeOrDie(); final DomElement parent = (DomElement) domNode.getParentNode(); if (parent != null) { domNode.setValue(parent.getAttribute(getName())); } domNode.remove(); }
/** * Detaches this attribute from the parent HTML element after caching the attribute value. */ public void detachFromParent() { final DomAttr domNode = getDomNodeOrDie(); final DomElement parent = (DomElement) domNode.getParentNode(); if (parent != null) { domNode.setValue(parent.getAttribute(getName())); } domNode.remove(); }