0

With phantomJS one can include a JavaScript library by doing page.inject("thelibrary.js"). Is it possible with the chromote package? I didn't find anything in the doc.

Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225

1 Answers1

0

One can do

      chrm <- Chrome$new(
        path = chromePath,
        args = "--disable-gpu --headless --remote-debugging-port=9222"
      )
      chromote <- Chromote$new(browser = chrm)
      session  <- ChromoteSession$new(parent = chromote)
      ids <- session$Page$navigate("about:blank")
      jsfile <- "path/to/jslibrary"
      library <- paste0(readLines(jsfile), collapse = "\n")
      . <- session$Runtime$evaluate(library)
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225