browser.get.attribute#
Functions#
value(xpath, attribute, timeout=None)
#
Get value from an attribute of an element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xpath | str | XPath of the element. | required |
attribute | str | Attribute name. | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
Type | Description |
---|---|
str | None | Value of the attribute. If the attribute does not exist, |
Example
Use "src"
as attribute to get the source URL from an <img>
image element.
Use "href"
as attribute to get the URL from an <a>
link element.
Or use other attributes to get the value from a <meta>
element in the <head>
section.
values(xpath, attribute, timeout=None)
#
Get values from an attribute of multiple elements. Assumes that the XPath targets multiple links.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xpath | str | XPath of the elements. | required |
attribute | str | Attribute name. | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Returns:
Type | Description |
---|---|
list[str | None] | Values of the attribute. If an attribute does not exist, |
Example
Use "src"
as attribute to get the source URL from <img>
image elements.
Use "href"
as attribute to get the URL from <a>
link elements.
Or use other attributes to get values from <meta>
elements in the <head>
section.