Skip to contents

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.

Usage

has_attr(x, name, value)

attr_contains(x, name, value)

has_value(x, value)

Arguments

x

A selenider_element object.

name

The name of the attribute.

value

The value of the attribute. For has_attr() and has_value(), this can be a string or a numeric value, while attr_contains() can only take a string.

Value

A boolean value: TRUE or FALSE.

See also

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")