Select or deselect select
and option
elements.
Arguments
- x
A
selenider_element
object representing aselect
oroption
element.- value
If
x
is aselect
element, the value of the option to select. Can be a character vector, in which case multiple options will be selected.- text
The text content of the option to select. This does not have to be a complete match, and multiple options can be selected.
- index
A vector of indexes. The nth option elements will be selected.
- timeout
How long to wait for the element to exist.
- reset_other
If
TRUE
(the default), the other options will be deselected.
Details
If no arguments apart from x
are supplied, and x
is a select
element,
all options will be deselected.
See also
Other actions:
elem_click()
,
elem_hover()
,
elem_scroll_to()
,
elem_set_value()
,
elem_submit()
Examples
html <- "
<select multiple>
<option value='a'>Option A.</option>
<option value='b'>Option B.</option>
<option value='c'>Option C.</option>
</select>
"
session <- minimal_selenider_session(html)
s("select") |>
elem_select("a")
s("select") |>
elem_select(text = c("Option A.", "Option C."))
s("select") |>
elem_select(index = 2, reset_other = FALSE)
# Reset selection
s("select") |>
elem_select()
s("select") |>
elem_select("b")