## ------------------------------------------------
## Method `SeleniumSession$new`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new(verbose = TRUE)
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$create_webelement`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
element <- session$find_element(using = "css selector", value = "*")
element2 <- session$create_webelement(id = element$id)
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$create_shadowroot`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
shadow_root <- session$create_shadowroot(id = "foo")
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$close`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$status`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$status()
session$close()
session$status()
}
## ------------------------------------------------
## Method `SeleniumSession$get_timeouts`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$get_timeouts()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$set_timeouts`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$set_timeouts(script = 100)
session$get_timeouts()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$navigate`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$current_url`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$current_url()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$back`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$navigate("https://www.tidyverse.org")
session$back()
session$current_url()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$forward`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$navigate("https://www.tidyverse.org")
session$back()
session$forward()
session$current_url()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$refresh`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$refresh()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$title`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$title()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$window_handle`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$window_handle()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$close_window`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$new_window()
session$close_window()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$switch_to_window`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
handle <- session$window_handle()
handle2 <- session$new_window()$handle
session$switch_to_window(handle)
session$switch_to_window(handle2)
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$window_handles`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
handles <- session$window_handles()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$new_window`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
handle <- session$new_window()$handle
session$switch_to_window(handle)
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$switch_to_frame`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$switch_to_frame()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$switch_to_parent_frame`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$switch_to_frame()
session$switch_to_parent_frame()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$get_window_rect`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$get_window_rect()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$set_window_rect`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$set_window_rect(width = 800, height = 600, x = 2, y = 3)
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$maximize_window`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$maximize_window()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$minimize_window`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$minimize_window()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$fullscreen_window`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$fullscreen_window()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$get_active_element`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$get_active_element()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$find_element`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "#download")
session$find_element(using = "xpath", value = "//div[contains(@class, 'col-xs')]/h1")
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$find_elements`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_elements(using = "css selector", value = "h1")
session$find_elements(using = "xpath", value = "//h1")
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$get_page_source`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$get_page_source()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$execute_script`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$execute_script("return 1")
session$execute_script("return arguments[0] + arguments[1]", 1, 2)
element <- session$find_element(value = "*")
session$execute_script("return arguments[0]", element)
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$execute_async_script`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$execute_async_script("
let callback = arguments[arguments.length - 1];
callback(1)
")
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$get_cookies`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$get_cookies()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$get_cookie`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$add_cookie(list(name = "foo", value = "bar"))
session$get_cookie("foo")
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$add_cookie`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$add_cookie(list(name = "my_cookie", value = "1"))
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$delete_cookie`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$add_cookie(list(name = "foo", value = "bar"))
session$delete_cookie("foo")
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$delete_all_cookies`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$delete_all_cookies()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$perform_actions`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
actions <- actions_stream(
actions_press(keys$enter),
actions_pause(0.5),
actions_release(keys$enter)
)
session$perform_actions(actions)
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$release_actions`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
actions <- actions_stream(
actions_press("a")
)
session$perform_actions(actions, release_actions = FALSE)
session$release_actions()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$dismiss_alert`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$execute_script("alert('hello')")
session$dismiss_alert()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$accept_alert`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$execute_script("alert('hello')")
session$accept_alert()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$get_alert_text`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$execute_script("alert('hello')")
session$get_alert_text()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$send_alert_text`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$execute_script("prompt('Enter text:')")
session$send_alert_text("hello")
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$screenshot`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$screenshot()
session$close()
}
## ------------------------------------------------
## Method `SeleniumSession$print_page`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$print_page()
session$close()
}
Run the code above in your browser using DataLab