Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to save screenshot using RSelenium

I am trying to access http://www.google.com and acquire its screenshot using RSelenium. The code for package installation and website access is as follows.

devtools::install_github('ropensci/RSelenium')
install.packages('wdman')

library(RSelenium)

library(wdman)
cDrv <- chrome()
eCaps <- list(chromeOptions = list(
  args = c('--headless', '--disable-gpu', '--window-size=1280,800')
))
remDr<- remoteDriver(browserName = "chrome", port = 4567L, 
                     extraCapabilities = eCaps)
remDr$open()
remDr$navigate("http://www.google.com")
remDr$screenshot(display = TRUE,file = 'test.png')

# clean up
remDr$close()
cDrv$stop()

The session info for this run is as follows.

R version 3.4.0 (2017-04-21)
    Platform: x86_64-apple-darwin15.6.0 (64-bit)
    Running under: OS X El Capitan 10.11.6

    Matrix products: default
    BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
    LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

    locale:
    [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     

    other attached packages:
    [1] wdman_0.2.2     RSelenium_1.7.3

    loaded via a namespace (and not attached):
     [1] Rcpp_0.12.14     XML_3.98-1.10    binman_0.1.0     withr_2.0.0      digest_0.6.14    assertthat_0.2.0
     [7] rappdirs_0.3.1   bitops_1.0-6     R6_2.2.2         jsonlite_1.5     semver_0.2.0     httr_1.3.1      
    [13] curl_2.8.1       xml2_1.1.1       devtools_1.13.3  subprocess_0.8.0 tools_3.4.0      yaml_2.1.14     
    [19] compiler_3.4.0   caTools_1.17.1   memoise_1.1.0    openssl_1.0 

Please correct me if I am wrong in my assumptions. The chrome driver accesses the website, captures a screenshot and stores it in test.png. The problem here is that, the code runs successfully but I am not able to find test.png. Is there something else I should do? Thank You in advance for the help!

like image 833
adhok Avatar asked Jan 29 '23 14:01

adhok


1 Answers

I get test.png only after deleting display = TRUE in remDr$screenshot:

remDr$screenshot(file = 'test.png')

Hope it can help you.

like image 90
Marco Sandri Avatar answered Jan 31 '23 09:01

Marco Sandri