Learn R Programming

crrri (version 0.0.13)

http-methods: Chrome Debugging Protocol HTTP methods

Description

When Chromium/Chrome is started in debugging mode, several HTTP endpoints are available. Using these endpoint, one can retrieve information from Chromium/Chrome or send commands, see https://chromedevtools.github.io/devtools-protocol/#endpoints.

Usage

fetch_version(host = "localhost", port = 9222, secure = FALSE)

list_targets(host = "localhost", port = 9222, secure = FALSE)

fetch_protocol(host = "localhost", port = 9222, secure = FALSE, local = FALSE)

new_tab(host = "localhost", port = 9222, secure = FALSE, url = NULL)

activate_target(host = "localhost", port = 9222, secure = FALSE, target_id)

close_target(host = "localhost", port = 9222, secure = FALSE, target_id)

inspect_target(host = "localhost", port = 9222, secure = FALSE, target_id)

Arguments

host

Character scalar, the host name of the application.

port

The remote debugging port (a numeric or a character scalar).

secure

A logical indicating whether a secure protocol shall be used.

local

Logical scalar, indicating whether the local version of the protocol (embedded in crrri) must be used or the protocol must be fetched remotely.

url

URL to open in a new tab.

target_id

Target (or tab) identifier.

Value

fetch_version(), list_targets(), fetch_protocols() and new_tab() return a list. activate_target() and close_target() returns a logical: TRUE is returned when the command succeeds, FALSE is returned if a wrong target_id is provided.

Examples

Run this code
# NOT RUN {
chrome <- Chrome$new()

# fetch information about headless Chrome
fetch_version()
# fetch the Chromium/Chrome protocol
protocol <- fetch_protocol()

# get the list of opened tabs
list_targets()
# open an url in a new tab
new_target <- new_tab(url = "http://r-project.org")
# the new tab is referenced in the list of opened tabs
list_targets()
# inspect a target in a web browser
if(interactive()) inspect_target(target_id = new_target$id)
# close the previous created tab
close_target(target_id = new_target$id)

chrome$close()
# }

Run the code above in your browser using DataLab