pz_find_nth() is pz_find() with which = n. With a target, it
pins the spec's nth match; an out-of-range n means no match, so
the call keeps auto-waiting like any pz_loc() resolution. Without
a target, it narrows the current scope to its nth element: one
eager slice of the pinned set, and an out-of-range n errors
immediately – the set was fixed at pin time, so there is nothing to
wait for.
Arguments
- ctx
A paparazzi context.
- n
The match to pick, 1-based (
"first"/"last"are thepz_find_first()/pz_find_last()wrappers, not values here).- target
A CSS selector string or a
pz_loc()spec.NULLnarrows the current scope; a union can't pick one match by position, and a spec that already carrieswhichis an error.- ...
Checked empty; reserved for future use.
- from_root
Resolve the target from the page root instead of the current scope? Requires a
target.
Examples
page <- pz_open(pz_example("tasks"))
# Mark the second task as done
page |>
pz_find_nth(2, target = ".task") |>
pz_act_click(".task-done")
pz_get_text(page, target = pz_loc(".task.done .task-title"))
#> [1] "File tax return" "Return library books"
pz_close(page)
