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 or bool 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"

title

title

Gets the title of a page.

Returns

str The text of the page title, as a string.

Example
>>> browser.title
"A Page Title"

url

url

Gets the url of a page.

Returns

str The url of the current page, as a string.

Example
>>> browser.url
"https://redandblack.io"