## ------------------------------------------------
## Method `WebElement$new`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
element <- session$find_element(using = "css selector", value = "#download")
session$close()
}
## ------------------------------------------------
## Method `WebElement$shadow_root`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
# Let's create our own Shadow Root using JavaScript
session$execute_script("
const div = document.createElement('div');
document.body.appendChild(div);
div.attachShadow({mode: 'open'});
")
element <- session$find_element(using = "css selector", value = "div")
shadow_root <- element$shadow_root()
session$close()
}
## ------------------------------------------------
## Method `WebElement$find_element`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
row <- session$find_element(using = "css selector", value = ".row")
logo_container <- row$find_element(using = "css selector", value = "p")
logo <- logo_container$find_element(using = "css selector", value = "img")
session$close()
}
## ------------------------------------------------
## Method `WebElement$find_elements`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
row <- session$find_element(using = "css selector", value = ".row")
links <- row$find_elements(using = "css selector", value = "a")
session$close()
}
## ------------------------------------------------
## Method `WebElement$is_selected`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "#download")$is_selected()
session$close()
}
## ------------------------------------------------
## Method `WebElement$get_attribute`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "a")$get_attribute("href")
session$close()
}
## ------------------------------------------------
## Method `WebElement$get_property`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "a")$get_property("href")
session$close()
}
## ------------------------------------------------
## Method `WebElement$get_css_value`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "a")$get_css_value("color")
session$close()
}
## ------------------------------------------------
## Method `WebElement$get_text`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "#download")$get_text()
session$close()
}
## ------------------------------------------------
## Method `WebElement$get_tag_name`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "#download")$get_tag_name()
session$close()
}
## ------------------------------------------------
## Method `WebElement$get_rect`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "#download")$get_rect()
session$close()
}
## ------------------------------------------------
## Method `WebElement$is_enabled`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "a")$is_enabled()
session$close()
}
## ------------------------------------------------
## Method `WebElement$computed_role`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "a")$computed_role()
session$close()
}
## ------------------------------------------------
## Method `WebElement$computed_label`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "a")$computed_label()
session$close()
}
## ------------------------------------------------
## Method `WebElement$click`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "a")$click()
session$close()
}
## ------------------------------------------------
## Method `WebElement$clear`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.google.com")
session$find_element(using = "css selector", value = "textarea")$clear()
session$close()
}
## ------------------------------------------------
## Method `WebElement$send_keys`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.google.com")
input <- session$find_element(using = "css selector", value = "textarea")
input$send_keys("Hello")
input$send_keys(key_chord(keys$control, "a"), key_chord(keys$control, "c"))
input$send_keys(keys$control, "v")
input$get_attribute("value")
session$close()
}
## ------------------------------------------------
## Method `WebElement$screenshot`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "a")$screenshot()
session$close()
}
## ------------------------------------------------
## Method `WebElement$is_displayed`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
session$find_element(using = "css selector", value = "a")$is_displayed()
session$close()
}
## ------------------------------------------------
## Method `WebElement$toJSON`
## ------------------------------------------------
if (FALSE) {
session <- SeleniumSession$new()
session$navigate("https://www.r-project.org")
result <- session$find_element(using = "css selector", value = "a")$toJSON()
result
jsonlite::toJSON(result, auto_unbox = TRUE)
session$close()
}
Run the code above in your browser using DataLab