Values¶
Values functions get the value of an element, or one of it’s attributes.
These functions operate on an element or browser, and return a string or boolean.
attribute¶
-
attribute
(attribute_name)¶
Gets the value of an attribute.
- Parameters
- attribute_name
str
The name of the attribute. For instance, “hidden”, or “class”.
- Returns
str
orbool
For boolean attributes like “hidden” a boolean is returned. For other attributes a string is returned.- Examples
>>> browser.get_element(id="hiding").attribute("hidden") True >>> browser.get_element(id="my_id").attribute("id") "my_id"
html¶
-
html
¶
Gets the html for an element or whole page.
- Returns
str
The html for the element or page, as a string.- Example
>>> browser.get_element(tag="p").html "<p>This is a paragraph.</p>"
text¶
-
text
¶
Gets the text of an element.
- Returns
str
The text of the element, as a string.- Example
>>> browser.get_element(tag="p").text "This is some text"