Skip to content

Commit

Permalink
Use remote-debugging-port for Chrome and selenium
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbythorpe committed Nov 2, 2023
1 parent 414734a commit a94cfc2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
32 changes: 26 additions & 6 deletions R/session.R
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,37 @@ create_selenium_client <- function(browser, port = 4444L, host = "localhost", ..
}
)

opts <- if (browser == "chrome" && !"capabilities" %in% ...names()) {
list(`goog:chromeOptions` = list(
args = list(
"remote-debugging-port=9222"

Check warning on line 421 in R/session.R

View check run for this annotation

Codecov / codecov/patch

R/session.R#L418-L421

Added lines #L418 - L421 were not covered by tests
)
))
} else {
NULL

Check warning on line 425 in R/session.R

View check run for this annotation

Codecov / codecov/patch

R/session.R#L425

Added line #L425 was not covered by tests
}

if (!res) {
stop_connect_selenium_server(timeout = 20)

Check warning on line 429 in R/session.R

View check run for this annotation

Codecov / codecov/patch

R/session.R#L428-L429

Added lines #L428 - L429 were not covered by tests
}

rlang::try_fetch(
selenium::SeleniumSession$new(
browser = browser,
port = port,
host = host,
...
),
if (!is.null(opts)) {
selenium::SeleniumSession$new(
browser = browser,
port = port,
host = host,
capabilities = opts,

Check warning on line 438 in R/session.R

View check run for this annotation

Codecov / codecov/patch

R/session.R#L432-L438

Added lines #L432 - L438 were not covered by tests
...
)
} else {
selenium::SeleniumSession$new(
browser = browser,
port = port,
host = host,

Check warning on line 445 in R/session.R

View check run for this annotation

Codecov / codecov/patch

R/session.R#L442-L445

Added lines #L442 - L445 were not covered by tests
...
)
},
error = function(e) {
stop_selenium_session(e)

Check warning on line 450 in R/session.R

View check run for this annotation

Codecov / codecov/patch

R/session.R#L449-L450

Added lines #L449 - L450 were not covered by tests
}
Expand Down
2 changes: 1 addition & 1 deletion R/utils-errors.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ stop_connect_selenium_server <- function(timeout = NULL, error = NULL, call = rl
stop_selenium_session <- function(error, call = rlang::caller_env()) {
cli::cli_abort(c(
"A Selenium session could not be started"
), class = "selenider_error_selenium_session", parent = error)
), class = "selenider_error_selenium_session", parent = error, call = call)

Check warning on line 190 in R/utils-errors.R

View check run for this annotation

Codecov / codecov/patch

R/utils-errors.R#L188-L190

Added lines #L188 - L190 were not covered by tests
}

stop_connect_rselenium_server <- function(count, error = NULL, res = NULL, driver = NULL, call = rlang::caller_env()) {
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-actions.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ test_that("JavaScript actions work", {
})

test_that("elem_scroll_to() works", {
if (Sys.getenv("SELENIDER_BROWSER") == "firefox") {
skip("Local files don't work on Firefox")
}
session <- selenider_test_session()

html <- "
Expand Down

0 comments on commit a94cfc2

Please sign in to comment.