Skip to contents

Take a screenshot of the current session state, saving this image to a file.

Usage

take_screenshot(file = NULL, view = FALSE, session = NULL)

Arguments

file

The file path to save the screenshot to.

view

Whether to open the interactively view the screenshot. If this is TRUE and file is NULL, the screenshot will be deleted after viewing.

session

A selenider_session object. If not specified, the global session object (the result of get_session()) is used.

Value

file, if it is not NULL. Otherwise, the session object is returned, invisibly.

See also

Other global actions: back(), current_url(), execute_js_fn(), get_page_source(), open_url(), reload()

Examples

session <- selenider_session()

open_url("https://www.google.com")

file_path <- withr::local_tempfile(fileext = ".png")

take_screenshot(file_path)