RLesur / crrri

A Chrome Remote Interface written in R
https://rlesur.github.io/crrri/
Other
157 stars 12 forks source link

Allow to run client without RStudio Viewer #87

Closed ColinFay closed 5 years ago

ColinFay commented 5 years ago

Especially when running chrome in non headless mode, we get the Viewer + the browser:

Screenshot 2019-10-10 at 14 43 55

This PR allows to get the client without opening the Viewer:

library(crrri)
chrome <- Chrome$new(
  pagedown::find_chrome(),
  debug_port = 12358L, 
  headless = FALSE
)
client <- chrome$connect(callback = function(client) {
  client$inspect(viewer = FALSE)
})

Page <- client$Page
Runtime <- client$Runtime
Page$navigate(url = "http://google.com")

chrome$close()

Screenshot 2019-10-10 at 14 46 17

Might also be useful when using {crrri} as a tool for testing web app.

cderv commented 5 years ago

I agree with Romain, this

client <- chrome$connect(callback = ~ NULL)

is the way to go get back the client, and not the promises.

If you don't want to get the inspector in the viewer, don't use it as callback and use another callback.