Value assertion (valueIs, valueContains, ...)
Checks on an element's value (e.g. the content of a text field), as opposed to its label. Same shape as Text Assertion.
The target is always "the element grabbed last" — selectors are not passed to these
commands. First grab the element with select (or exist / tap / etc.), then verify it:
select("#email").valueIs("test@example.com") // chain onto the return value
select("#email"); lastElement.valueIs("test@example.com") // explicit lastElement
select("#email"); valueIs("test@example.com") // implicit (the last grabbed element)
Arguments are (expected, requireVisible:, strict:, waitSeconds:) for the positive forms and (expected, strict:, waitSeconds:) for the negative forms, and (strict:, waitSeconds:) for the empty forms (valueMatchesDateFormat takes no strict: — see the table below). There is
no form that takes a selector. For the strings the implicit form cannot take as expected values, see Text Assertion.
Functions
| function | negation | comparison |
|---|---|---|
select(selector).valueIs(expected, requireVisible:, strict:, waitSeconds:) |
valueIsNot(expected, strict:, waitSeconds:) |
exact match |
valueContains(expected, requireVisible:, strict:, waitSeconds:) |
valueContainsNot(expected, strict:, waitSeconds:) |
substring match |
valueStartsWith(expected, requireVisible:, strict:, waitSeconds:) |
valueStartsWithNot(expected, strict:, waitSeconds:) |
prefix match |
valueEndsWith(expected, requireVisible:, strict:, waitSeconds:) |
valueEndsWithNot(expected, strict:, waitSeconds:) |
suffix match |
valueMatches(pattern, requireVisible:, strict:, waitSeconds:) |
valueMatchesNot(pattern, strict:, waitSeconds:) |
regular expression (substring; use ^…$ for a full match) |
valueMatchesDateFormat(format, requireVisible:, waitSeconds:) |
— | DateFormatter format string |
valueIsNotEmpty(strict:, waitSeconds:) |
valueIsEmpty(strict:, waitSeconds:) |
non-empty / empty |
Comparison follows the same "same if it looks the same" rule as text assertions (strict: to
disable it) — see Text Assertion for the full rule.
Example
select("#email").valueIs("test@example.com")
select("#email").valueContains("@example.com")
Notes
- Read a text field's contents with the
value*assertions; an empty field isvalueIsEmpty(the value of an empty field is empty in every UI framework).valueIs("")gives the same result. A text field'stextreturns the placeholder string in Compose Multiplatform (iOS), Flutter (iOS) and React Native, so do not asserttextIsEmpty/textIson a text field. - Negative forms and the empty checks do not consider visibility, and none of these commands take
scroll:— same rules as text assertions. - A chained check first evaluates against the value already grabbed, and only polls the device if that value doesn't yet satisfy the assertion — see Text Assertion.