Auto-waits for a match, then sets the value instantly – never staged
as typing, even while recording – and dispatches input and
change, so the page reacts exactly as if a user had made the edit.
Framework-controlled inputs (React and friends) notice the change:
the value is assigned through the browser's native value setter, not
the instance-level property those frameworks intercept.
Arguments
- ctx
A paparazzi context.
- value
A string (most controls), a number (range, number), or
TRUE/FALSE(checkboxes, radios).- ...
Checked empty; reserved for future use.
- target
A CSS selector string, a
pz_loc()spec, or a list of specs (a union matching any of them).NULLuses the current scope; at the root context a target is required.
Details
Covers text inputs and textareas (clear with pz_set_value(ctx, "")),
native <select> elements (matched by option value), checkboxes
and radios (TRUE/FALSE; a radio set to TRUE unchecks the others
in its group), and range, date, and number inputs. A contenteditable
element (plain or framework-driven, e.g. ProseMirror) has its
content replaced in one step.
See also
pz_act_type() for visible, keystroke-by-keystroke input and
pz_set_files().
Examples
page <- pz_open(pz_example("tasks"))
page |>
pz_set_value("Buy milk", target = "#task-title") |>
pz_set_value("high", target = "#task-priority") |>
pz_set_value(TRUE, target = "#task-urgent")
pz_get_value(page, target = list("#task-title", "#task-priority"))
#> [1] "Buy milk" "high"
pz_expect_checked(page, target = "#task-urgent")
# An empty string clears a text input
page |> pz_set_value("", target = "#task-title")
pz_expect_enabled(page, target = "#add-task", not = TRUE)
pz_close(page)
