pytoolbox.selenium.webelements.base module¶
- class pytoolbox.selenium.webelements.base.WebElement(*args, **kwargs)[source]¶
Bases:
FindMixin
,WebElement
- get_attribute(name)[source]¶
Gets the given attribute or property of the element.
This method will first try to return the value of a property with the given name. If a property with that name doesn’t exist, it returns the value of the attribute with the same name. If there’s no attribute with that name,
None
is returned.Values which are considered truthy, that is equals “true” or “false”, are returned as booleans. All other non-
None
values are returned as strings. For attributes or properties which do not exist,None
is returned.To obtain the exact value of the attribute or property, use
get_dom_attribute()
orget_property()
methods respectively.- Args:
name - Name of the attribute/property to retrieve.
Example:
# Check if the "active" CSS class is applied to an element. is_active = "active" in target_element.get_attribute("class")