RLesur / crrri

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

HTTP methods #56

Closed RLesur closed 5 years ago

RLesur commented 5 years ago

This PR will close #27

For now, the following functions are developed:

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)

My goal is to add new methods to CDPSession and CDPRemote built on top of these functions.

RLesur commented 5 years ago

I've added an inspect() method to the CDPSession class. The inspector opens by default in RStudio. I think this is convenient. So, I've modified the README to explain first how to play interactively with headless Chrome in a R session. Despite this is not the ultimate goal of crrri I think that R developers will be frustrated if they cannot interact through the R console.

Here are some screenshots I've added in the README Capture du 2019-04-28 18-17-37 Capture du 2019-04-28 18-18-19 Capture du 2019-04-28 18-18-57 Capture du 2019-04-28 18-20-03

cderv commented 5 years ago

Pretty big PR and very nice improvment ! It is really powerful ! I need to get my head around this to fully understand your changes and new features.

About the Browser vs Page Handling, should we aim at something like puppeteer:

This seems now possible with your changes. Don't know if it does matter or not to be able to controle Browser and page precisely. The new_tab endpoint seems ok. Maybe this will sort out by adding more examples.

What do you think ?

RLesur commented 5 years ago

Even if I tried to developed these new methods keeping in mind how puppeteer deals with browser/pages, I don't see a great value by changing the Remote/Chrome class. The Browser and Target domains seem to work now. IMO, this is sufficient. I will do only minor adjustments in the Remote class.

cderv commented 5 years ago

it is fine with we. Though, I still want to understand why browser Domain work whereas we don't have a connection to the browser target I'll see later.

RLesur commented 5 years ago

As detailed before, seven functions corresponding to HTTP endpoints are available in this PR.

Other changes:

CDPRemote/Chrome classes

CDPSession class

README file

Major update of the README file with screenshots to show first an interactive use case in RStudio.

RLesur commented 5 years ago

@cderv Thanks for your sharp eyes! I merge this branch now and we will improve the remaining points on master.