@refresh_when(PocoTargetRemovedException)<EOL><INDENT>def attr(self, name):<DEDENT>
<EOL>nodes = self._do_query(multiple=False)<EOL>val = self.poco.agent.hierarchy.getAttr(nodes, name)<EOL>if six.PY2 and isinstance(val, six.text_type):<EOL><INDENT>val = val.encode('<STR_LIT:utf-8>')<EOL><DEDENT>return val<EOL>
Retrieve the attribute of UI element by given attribute name. Return None if attribute does not exist.
If attribute type is :obj:`str`, it is encoded to utf-8 as :obj:`str` in Python2.7.

Args:
    name: 
        attribute name, it can be one of the following or any other customized type implemented by SDK

        - visible: whether or not it is visible to user
        - text: string value of the UI element
        - type: the type name of UI element from remote runtime
        - pos: the position of the UI element
        - size: the percentage size [width, height] in range of 0~1 according to the screen
        - name: the name of UI element
        - ...: other sdk implemented attributes

Returns:
    None if no such attribute or its value is None/null/nil/etc. Otherwise the attribute value is returned. The
    returned value type is json serializable. In both py2 and py3, if the attribute value in remote is a
    text-like object, the return value type will be :obj:`str`.

Raises:
    PocoNoSuchNodeException: when the UI element does not exists

.. note:: Exception :py:class:`NodeHasBeenRemovedException` is caught automatically.

See Also:
    :py:meth:`UI element attributes in poco sdk definition <poco.sdk.AbstractNode.AbstractNode.getAttr>`.