has_text {selenider}R Documentation

Does an element contain a pattern?

Description

has_text() checks that an element's inner text contains a string, while has_exact_text() checks that the inner text only contains the string. Both functions throw an error if the element does not exist in the DOM.

Usage

has_text(x, text)

has_exact_text(x, text)

Arguments

x

A selenider_element object.

text

A string, used to test the element's inner text.

Details

These functions do not implement a retry mechanism, and only test a condition once. Use elem_expect() or elem_wait_until() to use these conditions in tests.

Value

A boolean value: TRUE or FALSE.

See Also

Other conditions: has_attr(), has_css_property(), has_length(), has_name(), is_enabled(), is_present(), is_visible()

Examples


html <- "
<p>Example text</p>
<p class='empty'></p>
"

session <- minimal_selenider_session(html)

has_text(s("p"), "Example") # TRUE

has_exact_text(s("p"), "Example") # FALSE

has_exact_text(s("p"), "Example text") # TRUE

# has_exact_text() is useful for checking when there is no text,
# since has_text("") will always be TRUE.
has_exact_text(s(".empty"), "")


[Package selenider version 0.4.0 Index]