/** * Get the {@code id} attribute of this element. * * @return The id attribute, if present, or an empty string if not. */ public String id() { return attributes().getIgnoreCase("id"); }
private boolean isMetaRefresh(Node node) { if (!"meta".equalsIgnoreCase(node.nodeName())) { return false; } String attributeValue = node.attributes().getIgnoreCase("http-equiv"); return "refresh".equalsIgnoreCase(attributeValue.trim()); } }
final String classAttr = attributes().getIgnoreCase("class"); final int len = classAttr.length(); final int wantLen = className.length();
/** * Get an attribute's value by its key. <b>Case insensitive</b> * <p> * To get an absolute URL from an attribute that may be a relative URL, prefix the key with <code><b>abs</b></code>, * which is a shortcut to the {@link #absUrl} method. * </p> * E.g.: * <blockquote><code>String url = a.attr("abs:href");</code></blockquote> * * @param attributeKey The attribute key. * @return The attribute, or empty string if not present (to avoid nulls). * @see #attributes() * @see #hasAttr(String) * @see #absUrl(String) */ public String attr(String attributeKey) { Validate.notNull(attributeKey); if (!hasAttributes()) return EmptyString; String val = attributes().getIgnoreCase(attributeKey); if (val.length() > 0) return val; else if (attributeKey.startsWith("abs:")) return absUrl(attributeKey.substring("abs:".length())); else return ""; }
String attrKey = attr.getKey(); if (expect.hasKeyIgnoreCase(attrKey)) { return expect.getIgnoreCase(attrKey).equals(attr.getValue());
@Override public String getAttribute(String name) { return cachedElement.attributes().getIgnoreCase(name); }
public CachedHtmlElement(WebElement elementToCache) { try { rectangle = elementToCache.getRect(); location = new Point(rectangle.x, rectangle.y); size = new Dimension(rectangle.width, rectangle.height); } catch (WebDriverException e) { location = elementToCache.getLocation(); size = elementToCache.getSize(); rectangle = new Rectangle(location, size); } cachedElement = Jsoup.parseBodyFragment(elementToCache.getAttribute("outerHTML")).body().child(0); if ("option".equals(cachedElement.tagName()) || ("input".equals(cachedElement.tagName()) && "checkbox".equals(cachedElement.attributes().getIgnoreCase("type"))) || ("input".equals(cachedElement.tagName()) && "radio".equals(cachedElement.attributes().getIgnoreCase("type"))) ) { selected = elementToCache.isSelected(); } else { selected = false; } realElement = elementToCache; }