2

I am trying to learn using RSelenium. I am stuck with just trying to start the server using rsDriver. I am simply trying to run the code below and got the following error:

rD <- rsDriver()
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
Error in open.connection(con, "rb") : 
  Peer certificate cannot be authenticated with given CA certificates

I searched around stack overflow and found out we can give options to rsDriver using below but I still got error:

my_extra <- list("--ignore-ssl-errors=true", "--ssl-protocol=tlsv1", "--web-security=no")
rs <- rsDriver(extraCapabilities = my_extra)
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
Error in open.connection(con, "rb") : 
  Peer certificate cannot be authenticated with given CA certificates

Is there anything else I am missing?

for httr::GET function, I am able to bypass the SSL Certificate using:

set_config(config(ssl_verifypeer=0L)). 

But this method does not work for RSelenium::rsDriver.

Here is my system spec: My OS: Microsoft Windows 10

R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
[1] RCurl_1.95-4.8  bitops_1.0-6    httr_1.2.1      wdman_0.2.2    
[5] RSelenium_1.7.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.12     XML_3.98-1.9     binman_0.1.0     assertthat_0.2.0
 [5] R6_2.2.2         jsonlite_1.5     semver_0.2.0     curl_2.7        
 [9] tools_3.4.1      yaml_2.1.14      compiler_3.4.1   caTools_1.17.1  
[13] openssl_0.9.6
addicted
  • 2,901
  • 3
  • 28
  • 49
  • See https://github.com/johndharrison/wdman/issues/9 – jdharrison Jul 25 '17 at 05:05
  • I tried this command: **httr::with_config(config(ssl_verifypeer=0L),wdman::selenium(retcommand=TRUE))**. But still it doesn't work. Exact same error: Peer certificate cannot be authenticated with given CA certificates. Is there any alternative way of starting the server? Maybe using some other method which I can pass an "ignore SSL certificate" command? – addicted Jul 25 '17 at 06:01
  • The issue is with `jsonlite::fromJSON`. The underlying package `curl` needs to be passed the `ssl_verifypeer` argument. In the issue given you can do this by mocking the function. – jdharrison Jul 25 '17 at 06:07

1 Answers1

2

rsDriver uses the binman package to handle the downloading of relevant binaries. The selenium project lists its release in a JSON file at https://www.googleapis.com/storage/v1/b/selenium-release/o You should have the same issue if you try:

jsonlite::fromJSON("https://www.googleapis.com/storage/v1/b/selenium-release/o")

You can mock the relevant curl fundtion using something like:

my_new_handle <- function(...){
  print("mocking")
  h <- .Call(curl:::R_new_handle, PACKAGE = "curl")
  curl:::handle_setopt(h, ..., ssl_verifypeer = FALSE)
  h
}
testthat::with_mock(
  `curl::new_handle` = my_new_handle,
  {
    selCommand <- httr::with_config(config(ssl_verifypeer=0L),wdman::selenium(‌​retcommand=TRUE))
  }
)
jdharrison
  • 30,085
  • 4
  • 77
  • 89
  • You're right. I do get the same issue with jsonlite. However, I manage to download seleniumserver, chromedriver, firefoxdriver, and phantomjs using the set functions you provided. Do I have to keep using the mocking command as well with rsDriver? – addicted Jul 25 '17 at 06:52
  • Once the drivers are downloaded you can set `check = FALSE` as an argument in `rsDriver` and it shouldn't check for updated drivers. – jdharrison Jul 25 '17 at 06:54
  • I put in the check = FALSE but rsDriver still checks for selenium server versions. (I know this digress a bit from my original question. But I am still just trying to make rsDriver work.) – addicted Jul 25 '17 at 07:01
  • 1
    The check argument was being incorrectly passed in the RSelenium version on CRAN. Use the dev version from github. `devtools::install_github("ropensci/RSelenium")`. See https://github.com/ropensci/RSelenium/issues/123 – jdharrison Jul 25 '17 at 07:03
  • Thanks! I downloaded the package and it does work. But when I try to initiate rD <- rsdriver(check=FALSE), it returns this error : Error in `[.data.frame`(as.data.frame(x[["client"]]$sessionInfo), c("browserName", : undefined columns selected. Sorry to disturb you with so many questions but feels like just getting this line to work is a bit tough. – addicted Jul 25 '17 at 07:17