Get attribute value.

@param element The element to get attribute value
@param attr The attribute name
@return Value of attribute if present and null in other case
761448
private String getAttributeSmart(Element element, String attr)
   {
      return element.hasAttribute(attr) ? element.getAttribute(attr) : null;
   }
498983
def get_attribute(self, selector, attribute, by=By.CSS_SELECTOR,
                      timeout=settings.SMALL_TIMEOUT):
        
        if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
            timeout = self.__get_new_timeout(timeout)
        if page_utils.is_xpath_selector(selector):
            by = By.XPATH
        if page_utils.is_link_text_selector(selector):
            selector = page_utils.get_link_text_from_selector(selector)
            by = By.LINK_TEXT
        self.wait_for_ready_state_complete()
        time.sleep(0.01)
        element = page_actions.wait_for_element_present(
            self.driver, selector, by, timeout)
        try:
            attribute_value = element.get_attribute(attribute)
        except (StaleElementReferenceException, ENI_Exception):
            self.wait_for_ready_state_complete()
            time.sleep(0.06)
            element = page_actions.wait_for_element_present(
                self.driver, selector, by, timeout)
            attribute_value = element.get_attribute(attribute)
        if attribute_value is not None:
            return attribute_value
        else:
            raise Exception("Element {%s} has no attribute {%s}!" % (
                selector, attribute))
690920
Element getElementById(String name) {
        for (Attr attr : attributes) {
            if (attr.isId() && name.equals(attr.getValue())) {
                return this;
            }
        }

        /*
         * TODO: Remove this behavior.
         * The spec explicitly says that this is a bad idea. From
         * Document.getElementById(): "Attributes with the name "ID"
         * or "id" are not of type ID unless so defined.
         */
        if (name.equals(getAttribute("id"))) {
            return this;
        }

        for (NodeImpl node : children) {
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                Element element = ((ElementImpl) node).getElementById(name);
                if (element != null) {
                    return element;
                }
            }
        }

        return null;
    }
1153726
@Override
	public String getAttribute(String attributeName) throws WidgetException {
		try {
			WebElement webElement = null;
			String attr = null;

			// WebDriver get attribute
			try {
				webElement = findElement();
				attr = webElement.getAttribute(attributeName);
				highlight(HIGHLIGHT_MODES.GET);
			} catch (NoSuchElementException e) {
				throw e;
			}

			if (attr != null && !attr.equals("")) {
				return attr;
			}

			return "";
		} catch (Exception e) {
			throw new WidgetException("Error while fetching attribute " + attributeName, locator, e);
		}
	}
191010
public Object getAttributeValue(String attributeName) {
		Attribute attribute = getAllAttributes().get(attributeName);
		if (attribute != null) {
			return attribute.getValue();
		}
		return null;
	}
1072523
function get(attr) {
        if (!~attr.indexOf('.')) return this.attributes[attr];

        var result = attr
          , structure = this.attributes;

        for (var paths = attr.split('.'), i = 0, length = paths.length; i < length && structure; i++) {
          result = structure[+paths[i] || paths[i]];
          structure = result;
        }

        return result || this.attributes[attr];
      }
1210641
public final String getAttribute(final BodyQName attr) {
        Map<BodyQName, String> attrs = getAttributes();
        return attrs.get(attr);
    }
890076
public Attribute getAttribute(String name)
  {
    for (int i = _attributes.size() - 1; i >= 0; i--) {
      Attribute attr = _attributes.get(i);

      if (attr.getName().equals(name))
        return attr;
    }

    return null;
  }
60165
public String getAttribute(int elementId, String value)
    {
        return table.getKeyByValue(new Integer(elementId)) + "=\"" + value + "\"";
    }
154724
public static Boolean getAttributeBoolean(Tag tag, String attrName, Boolean defaultValue) {
	Literal lit = getAttributeLiteral(tag, attrName, null);
	if (lit == null) return defaultValue;
	return lit.getBoolean(defaultValue);
    }
713953
@Override
    public List<Object> getAttributeValues(final String name) {
        final List<Object> values = this.attributes.get(name);
        if (values == null) {
            return null;
        }

        return values;
    }
156251
@SuppressWarnings("unchecked")
    public <T> T attribute(String attribute) {
        return (T) servletRequest.getAttribute(attribute);
    }
747873
public Object getValue(String attributeName) {
        if (attributeName != null) {
            return values.get(attributeName);
        }
        return null;
    }
927831
public static String extractAttributeValue(final String attrName, final Node doc, final boolean throwException) throws XMLParsingException {
        String xpath = "descendant-or-self::*/@" + attrName;
        Nodes nodes = doc.query(xpath);
        for (int i = 0; i < nodes.size(); i++) {
            if (nodes.get(i) instanceof Attribute) {
                return nodes.get(i).getValue();
            }
        }
        if (throwException) {
            throw new XMLParsingException("No Attribute " + attrName + " in document:\n" + doc.toXML());
        } else {
            return null;
        }
    }
429035
private function getAttr(\DOMNode $node, $attr, $default = null)
    {
        $attr = $node->attributes->getNamedItem($attr);
        return isset($attr) ? $attr->nodeValue : $default;
    }
361625
function getAttribute(node, attrName) {
	attrName = attrName.toLowerCase();
	return node && node.open.attributes.find(attr => attr.name.value.toLowerCase() === attrName);
}
1128220
public static String getCascadeValue(final Element elem, final String attrName) {
        Element current = elem;
        while (current != null) {
            final Attr attr = current.getAttributeNode(attrName);
            if (attr != null) {
                return attr.getValue();
            }
            final Node parent = current.getParentNode();
            if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
                current = (Element) parent;
            } else {
                break;
            }
        }
        return null;
    }