pz_expect_url() passes when the page's URL satisfies url. It works
from any context, scoped or root: the URL belongs to the page, not to
an element.
Outside of testthat, a failure aborts with a classed error of class
"paparazzi_expectation_failure"; inside testthat, the failure is
reported as a test failure instead. See pz_expect_exists() for the
retry, timeout, and bridge behavior shared by all expectations.
Usage
pz_expect_url(
ctx,
url,
...,
match = c("contains", "exact", "regex"),
not = FALSE,
timeout = NULL
)Arguments
- ctx
A paparazzi context.
- url
The expected URL, a single string.
- ...
Checked empty; reserved for future use.
- match
How to compare
url:"contains"(substring),"exact", or"regex"(an R regex matched withgrepl()).- not
Invert the check.
- timeout
Seconds to wait for the expectation to pass;
NULL(default) uses the session default,0checks once.
Examples
if (FALSE) { # paparazzi:::examples_run()
page <- pz_open(pz_example("tasks"))
page |> pz_expect_url("tasks.html")
page |>
pz_act_click(pz_loc(".filters a", has_text = "Done")) |>
pz_expect_url("#done$", match = "regex")
pz_close(page)
}
