select_option: Page class: Select an option from a dropdown

View source: R/actions.R

select_optionR Documentation

Page class: Select an option from a dropdown

Description

The select_option function selects an option from a dropdown element. It can either locate the dropdown using a provided selector or by referencing an element previously located.

Usage

select_option(page_df, option, selector = NULL)

Arguments

page_df

A data frame containing page information, including the page_id column. This data frame is used to identify the page object where the dropdown should be selected.

option

A character string representing the option to select from the dropdown.

selector

(Optional) A character string representing the selector of the dropdown. If provided, the dropdown will be located using the selector. If not provided, the elem_id column from page_df will be used to reference a previously located element.

Value

The updated page_df data frame.

Examples

# Create a page_df data frame
page_df <- data.frame(page_id = "my_page")

# Select an option from a dropdown using a selector
select_option(page_df, "Option 1", selector = "#myDropdown")

# Select an option from a dropdown using a previously located element
page_df <- get_by_role(page_df, "combobox")
select_option(page_df, "Option 2")


benjaminguinaudeau/playwrightr documentation built on Nov. 8, 2023, 8:36 p.m.