Skip to contents

[Experimental]

Downloads the latest release of Selenium Server, and then runs it as a background process. You must have Java installed for this command to work.

Usage

selenium_server(
  version = "latest",
  host = "localhost",
  port = 4444L,
  selenium_manager = TRUE,
  interactive = TRUE,
  stdout = NULL,
  stderr = NULL,
  verbose = TRUE,
  temp = TRUE,
  path = NULL,
  extra_args = c(),
  ...
)

Arguments

version

The version of Selenium Server to download and run. By default, the latest major or minor release is used.

host

The host to run the server on.

port

The port to run the server on.

selenium_manager

Whether to enable Selenium Manager, which will automatically download any missing drivers. Defaults to TRUE.

interactive

By default, if you don't have a version downloaded, you will be prompted to confirm that you want to download it, and the function will error if rlang::is_interactive() returns FALSE. To allow this function to work in a non-interactive setting, set this to FALSE.

stdout, stderr

Passed into processx::process$new(). Set to "|" to capture output and error logs from the server, which can then be accessed with server$read_output() and server$read_error().

verbose

Passed into utils::download.file(). Note that setting this to FALSE will not disable the prompt if a file needs to be downloaded.

temp

Whether to use a temporary directory to download the Selenium Server .jar file. This will ensure that the file is deleted after it is used, but means that you will have to redownload the file with every new R session. If FALSE, the file is saved in your user data directory.

path

The path where the downloaded Selenium Server .jar file will be saved. Overrides temp.

extra_args

A character vector of extra arguments to pass into the Selenium Server call. See the list of options here: https://www.selenium.dev/documentation/grid/configuration/cli_options/

...

Passed into processx::process$new().

Value

A SeleniumServer object. Call server$kill() to stop the server.

Details

This command respects the JAVA_HOME environment variable when attempting to find the java executable. Otherwise, Sys.which() is used.

See also

The package website for more ways to start the Selenium server.

Examples

if (FALSE) { # \dontrun{
# Disables the prompt that asks you whether you want to download Selenium server
server <- selenium_server(interactive = FALSE)

# Saves the server in your user data directory
server <- selenium_server(temp = FALSE)
server$kill()

# The server doesn't have to be downloaded again
server <- selenium_server(temp = FALSE)

# Here we use extra arguments to increase the timeout of client sessions,
# allowing sessions to stay open for longer without being automatically
# terminated.
server <- selenium_server(extra_args = c("--session-timeout", "3000"))
} # }