has_attr()
checks that an element's attribute matches a value, while
attr_contains()
checks that an element's attribute contains a value.
has_value()
is a shortcut for has_attr("value")
: it checks that an
element's value matches a string or number.
Arguments
- x
A
selenider_element
object.- name
The name of the attribute.
- value
The value of the attribute. For
has_attr()
andhas_value()
, this can be a string or a numeric value, whileattr_contains()
can only take a string.
See also
Other conditions:
has_css_property()
,
has_length()
,
has_name()
,
has_text()
,
is_enabled()
,
is_present()
,
is_visible()
Examples
html <- "
<input class='myclass' value='1.0' data-customattr='Custom attribute text'>
"
session <- minimal_selenider_session(html)
has_attr(s("input"), "class", "myclass")
has_attr(s("input"), "value", 1)
has_value(s("input"), 1)
attr_contains(s("input"), "data-customattr", "Custom attribute")