Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbythorpe committed Dec 31, 2023
1 parent 16c541b commit 0514066
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/actions.R
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ element_set_value <- function(x, text, session, driver) {
} else {
x$sendKeysToElement(list(rest))

Check warning on line 724 in R/actions.R

View check run for this annotation

Codecov / codecov/patch

R/actions.R#L724

Added line #L724 was not covered by tests
}
} else if (type == "other-input") {
} else {
element_focus(x, session = session, driver = driver)

Check warning on line 727 in R/actions.R

View check run for this annotation

Codecov / codecov/patch

R/actions.R#L727

Added line #L727 was not covered by tests

execute_js_fn_on(paste0("function(x) {
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-actions.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ test_that("actions work", {
elem_select(selection)

elem_expect(output, has_text("0"))

editable <- s("#editable-text")
editable_output <- s("#editable-text-output")

elem_expect(editable_output, has_exact_text(""))

elem_set_value(editable, "my text")

elem_expect(editable_output, has_text("my text"))
})

test_that("get_element_for_selection() works", {
Expand Down
18 changes: 17 additions & 1 deletion tests/testthat/test-properties.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_that("selenider_element properties work", {
session <- selenider_test_session()

open_url("https://ashbythorpe.github.io/selenider/articles/test-site.html")
open_url("https://ashbythorpe.github.io/selenider/dev/articles/test-site.html")

expect_equal(elem_name(s("#toggle_div")), "button")
expect_equal(elem_name(s(".actions-form")), "form")
Expand All @@ -26,4 +26,20 @@ test_that("selenider_element properties work", {

# Computed style
expect_true(elem_css_property(s("#form-output"), "color") %in% c("rgb(255, 0, 0)", "rgba(255, 0, 0, 1)"))

elem_select(s("#selection"), 1)

expect_equal(elem_value(s("#selection")), "1")

elem_select(s("#multiple-selection"), c(2, 3))

expect_equal(elem_value(s("#multiple-selection")), c("2", "3"))

editable <- s("#editable-text")

expect_equal(elem_value(editable), "Editable text")

elem_set_value(editable, "my text")

expect_equal(elem_value(editable), "my text")
})

0 comments on commit 0514066

Please sign in to comment.