press: Page class: Press a key

View source: R/actions.R

pressR Documentation

Page class: Press a key

Description

The press function simulates pressing a key on the keyboard. It can either locate the element using a provided selector or by referencing an element previously located.

Usage

press(page_df, key, 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 key press should be simulated.

key

A character string representing the key to press.

selector

(Optional) A character string representing the selector of the element. If provided, the element 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")

# Press a key using a selector
press(page_df, "Enter", selector = "#myElement")

# Press a key using a previously located element
page_df <- get_by_role(page_df, "textbox")
press(page_df, "Enter")


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