RSelenium/carbonate Windows
maelle opened this issue · comments
Describe the bug
I can't take a screenshot of the object.
To Reproduce
# carbonate
reprex::reprex(plot(1:10),
outfile = "demo_carbonate",
venue = "r")
#> Preparing reprex as .R file:
#> * demo_carbonate_reprex.R
#> Rendering reprex...
#> Writing reprex markdown:
#> * demo_carbonate_reprex.md
#> Writing reprex as commented R script:
#> * demo_carbonate_reprex_rendered.R
#> Rendered reprex is on the clipboard.
x <- carbonate::carbon$new(readLines('demo_carbonate_reprex_rendered.R'))
x$carbonate(file = 'myfile.png')
#> starting chrome session...
#> checking chromedriver versions:
#> BEGIN: PREDOWNLOAD
#> BEGIN: DOWNLOAD
#> BEGIN: POSTDOWNLOAD
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#>
#>
#> Selenium message:no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/main/div[2]/div/div[1]/div[5]/div"}
#> (Session info: chrome=69.0.3497.100)
#> (Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Windows NT 10.0.17134 x86_64)
#> Error: attempt to fetch image from carbon servers failed,
#> please check network connectivity and try again
Created on 2018-09-29 by the reprex package (v0.2.1)
Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.5.0 (2018-04-23)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.1252
#> tz Europe/Paris
#> date 2018-09-29
#> Packages -----------------------------------------------------------------
#> package * version date source
#> assertthat 0.2.0 2017-04-11 CRAN (R 3.5.0)
#> backports 1.1.2 2017-12-13 CRAN (R 3.5.0)
#> base * 3.5.0 2018-04-23 local
#> base64enc 0.1-3 2015-07-28 CRAN (R 3.5.0)
#> binman 0.1.1 2018-07-18 CRAN (R 3.5.1)
#> bitops 1.0-6 2013-08-17 CRAN (R 3.5.0)
#> callr 3.0.0 2018-08-24 CRAN (R 3.5.1)
#> carbonate 0.0.1 2018-09-29 Github (yonicd/carbonate@0c8b769)
#> caTools 1.17.1.1 2018-07-20 CRAN (R 3.5.1)
#> clipr 0.4.1 2018-06-23 CRAN (R 3.5.0)
#> compiler 3.5.0 2018-04-23 local
#> crayon 1.3.4 2017-09-16 CRAN (R 3.5.0)
#> curl 3.2 2018-03-28 CRAN (R 3.5.0)
#> datasets * 3.5.0 2018-04-23 local
#> debugme 1.1.0 2017-10-22 CRAN (R 3.5.0)
#> devtools 1.13.6 2018-06-27 CRAN (R 3.5.1)
#> digest 0.6.17 2018-09-12 CRAN (R 3.5.1)
#> evaluate 0.11 2018-07-17 CRAN (R 3.5.1)
#> fs 1.2.6 2018-08-23 CRAN (R 3.5.1)
#> graphics * 3.5.0 2018-04-23 local
#> grDevices * 3.5.0 2018-04-23 local
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.5.1)
#> httr 1.3.1 2017-08-20 CRAN (R 3.5.0)
#> jsonlite 1.5 2017-06-01 CRAN (R 3.5.0)
#> knitr 1.20 2018-02-20 CRAN (R 3.5.0)
#> magick 1.9 2018-05-11 CRAN (R 3.5.0)
#> magrittr 1.5 2014-11-22 CRAN (R 3.5.0)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
#> methods * 3.5.0 2018-04-23 local
#> openssl 1.0.2 2018-07-30 CRAN (R 3.5.0)
#> processx 3.2.0 2018-08-16 CRAN (R 3.5.1)
#> ps 1.1.0 2018-08-10 CRAN (R 3.5.1)
#> R6 2.2.2 2017-06-17 CRAN (R 3.5.0)
#> rappdirs 0.3.1 2016-03-28 CRAN (R 3.5.0)
#> Rcpp 0.12.18 2018-07-23 CRAN (R 3.5.0)
#> reprex 0.2.1 2018-09-16 CRAN (R 3.5.1)
#> rlang 0.2.2 2018-08-16 CRAN (R 3.5.1)
#> rmarkdown 1.10 2018-06-11 CRAN (R 3.5.0)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3)
#> RSelenium 1.7.4 2018-09-18 CRAN (R 3.5.1)
#> rtweet 0.6.8 2018-09-28 CRAN (R 3.5.0)
#> semver 0.2.0 2017-01-06 CRAN (R 3.5.1)
#> stats * 3.5.0 2018-04-23 local
#> stringi 1.2.4 2018-07-23 local
#> stringr 1.3.1 2018-05-10 CRAN (R 3.5.0)
#> subprocess 0.8.3 2018-08-13 CRAN (R 3.5.1)
#> tools 3.5.0 2018-04-23 local
#> utils * 3.5.0 2018-04-23 local
#> wdman 0.2.4 2018-07-21 CRAN (R 3.5.1)
#> whisker 0.3-2 2013-04-28 CRAN (R 3.4.0)
#> withr 2.1.2 2018-03-15 CRAN (R 3.4.4)
#> XML 3.98-1.16 2018-08-19 CRAN (R 3.5.1)
#> xml2 1.2.0 2018-01-24 CRAN (R 3.5.0)
#> yaml 2.2.0 2018-07-25 CRAN (R 3.5.1)
it looks like an RSelenium
bug/wrong setup though. Happy to hear any thought and to take my bug report/own mistake elsewhere.
I don't have a windows OS on hand. the only place RSelenium is being 'setup' is here and here.
In the latter the disable-gpu
switch is meant to be for windows.
I have a feeling that @juyeongkim would have a quicker answer on that.
@juyeongkim I can provide more info and we can move this convo to the RSelenium repo if you want.
@maelle i just ran it on my OS it gets the same thing as you. the carbon page must have changed. I'll reset the xpaths (not the first time that page has been changed). Thanks for catching this.
Ah very cool! Happy to be of help, looking forward to getting PNGs! 🎉
The ci passed. So once you verify for windows I’ll pr this branch.
Installing now!
Yay it worked! Thanks!
Btw have you thought of wrapping the source code of carbon.js itself to create the pic locally? Is it even possible?
Actually an image was created, but not saved to disk, is this normal?
i.e. I then had to run magick::image_write(x$carbons, "myfile.png")
to save the image.
(and sorry for all the questions... such a neat package!!)
great questions :).
using the carbon.js script was my first instinct too to create an htmlwidget, but they dont give access to the raw script (only throught the website).
the default to save to disk is tempdir()
. to set the output dir you need to do
x$chrome_pref$download.default_directory <- MYPATH
example from the readme
using the carbon.js script was my first instinct too to create an htmlwidget, but they dont give access to the raw script (only throught the website).
Interesting! Now I wonder about the possibility to make a similar, less pretty/customizable tool via magick::image_annotate
(that supports different fonts) 🤔
Oops sorry for not reading the docs enough! Would it make sense for carbonate
to expose the dir
argument? i.e.
x$carbonate(file = 'myfile.png', dir = getwd())
with dir
being x$chrome_pref$download.default_directory
by default?
That would be nice, but chrome pref controls The download dir. what may work is to have an exposed method that wraps around that nested element to simplify the api.
The first comment about using magick instead sounds like a big undertaking, carbonjs is pretty complex to mimic (at least for me ;))
Reread your dir suggestion. Could work, but I’m not next to a computer for most of the day. Your welcome to fork and play around with it. Improving the api is always welcome.
Reg the non-carbonate solution, do you know of https://github.com/ropenscilabs/codefinch? It uses rendering to PDF and then rendering of the PDF to an image (via pdftools
). Not as pretty, but then one doesn't need a website. :-)
Will make a small try for the dir
.
sorry I won't have time to do the dir
edit myself.
No worries, I’ll take a look tonight.
I think user experience would increase once headless chrome download to location bug is fixed.
Awesome, thank you!