elem_expect_all {selenider} | R Documentation |
Test conditions on multiple elements
Description
elem_expect_all()
and elem_wait_until_all()
are complements to
elem_expect()
and elem_wait_until()
that test conditions on
multiple elements in an element collection.
Usage
elem_expect_all(x, ..., testthat = NULL, timeout = NULL)
elem_wait_until_all(x, ..., timeout = NULL)
Arguments
x |
A |
... |
< |
testthat |
Whether to treat the expectation as a |
timeout |
The number of seconds to wait for a condition to pass. If not
specified, the timeout used for |
Details
If x
does not contain any elements, elem_expect_all()
and
elem_wait_until_all()
will succeed. You may want to first verify that
at least one element exists with has_at_least()
.
elem_expect_all()
and elem_wait_until_all()
can be thought of as
alternatives to the use of all(vapply(FUN.VALUE = logical(1)))
(or
purrr::every()
) within elem_expect()
and elem_wait_until()
.
For example, the following two expressions are equivalent (where x
is an
element collection).
elem_expect( x, \(element) all(vapply(as.list(element), is_present, logical(1))) ) elem_expect_all(x, is_present)
However, the second example will give a more detailed error message on failure.
Value
elem_expect_all()
returns x
, invisibly.
elem_wait_until_all()
returns a boolean flag: TRUE if the test passes,
FALSE otherwise.
See Also
-
is_present()
and other conditions for predicates for HTML elements. (If you scroll down to the See also section, you will find the rest).
Examples
html <- "
<div id='div1'>Content 1</div>
<div id='div2'>Content 2</div>
<div id='div3' style='display:none;'>Content 3</div>
<div id='div4'>Content 4</div>
"
session <- minimal_selenider_session(html)
ss("div") |>
elem_expect_all(is_visible, timeout = 0.1) |>
try()
ss("div")[-3] |>
elem_expect_all(is_visible)