click: Page class: Click on an element

View source: R/actions.R

clickR Documentation

Page class: Click on an element

Description

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

Usage

click(
  page_df,
  selector = NULL,
  index = 1,
  button = "left",
  click_count = 1,
  delay = 0,
  force = FALSE,
  modifiers = NULL,
  no_wait_after = FALSE,
  position = NULL,
  timeout = 30000,
  trial = FALSE
)

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 click should be performed.

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.

button

(Optional) A character string representing the button to use for the click. Possible values are "left", "right", or "middle". Defaults to "left".

click_count

(Optional) An integer representing the number of clicks to perform. Defaults to 1.

delay

(Optional) A float value representing the time to wait between mousedown and mouseup in milliseconds. Defaults to 0.

force

(Optional) A boolean value indicating whether to bypass the actionability checks. Defaults to false.

modifiers

(Optional) A list of modifier keys to press during the click. Possible values are "Alt", "Control", "Meta", and "Shift". If not specified, the currently pressed modifiers are used.

no_wait_after

(Optional) A boolean value indicating whether to wait for any subsequent navigations to happen. If set to true, it bypasses the waiting. Defaults to false.

position

(Optional) A dictionary specifying the x and y coordinates of the click relative to the top-left corner of the element's padding box. If not specified, some visible point of the element is used.

timeout

(Optional) A float value representing the maximum time in milliseconds for the click operation. Defaults to 30000 (30 seconds). Pass 0 to disable the timeout.

trial

(Optional) A boolean value indicating whether to perform the action or only perform the actionability checks without actually clicking. Defaults to false.

Value

The updated page_df data frame.

Examples

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

# Perform a click using a selector
click(page_df, selector = "#myElement", button = "left", click_count = 2, delay = 100, force = TRUE, modifiers = c("Control", "Shift"), no_wait_after = TRUE, position = list(x = 10, y = 10), timeout = 5000, trial = TRUE)

# Perform a click using a previously located element
page_df <- get_by_text(page_df, "Click Me")
click(page_df, button = "right")


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