RSelenium
RSelenium copied to clipboard
Driver info: driver.version: unknown
Since Firefox version 48, Mozilla requires all add-ons to be signed. Until recently, Firefox support in Selenium was exclusively provided by an add-on. As this add-on is not currently signed, this solution does not work with the latest Firefox releases. As an alternative, Mozilla are working on a WebDriver specification compliant implementation named GeckoDriver. Please note that the specification is not complete, and that Selenium itself does not comply with the specification at this time. This means that features previously available through Selenium will not be available using GeckoDriver.
Currently we would advise against using the latest firefox/geckodriver with selenium untill the w3c webdriver specification is complete. If you wish to use firefox we would advise using an older version via a Docker image. See the RSelenium Docker vignette for more detail:
http://rpubs.com/johndharrison/RSelenium-Docker
If your issue is not with geckodriver/firefox please fill out the template
Operating System
Windows 7, SP1,
Selenium Server version (selenium-server-standalone-3.0.1.jar etc.)
not sure how to check this
Browser version (firefox 50.1.0, chrome 54.0.2840.100 (64-bit) etc.)
firefox 64, 64-bit
Other driver version (chromedriver 2.27, geckodriver v0.11.1, iedriver x64_3.0.0, PhantomJS 2.1.1 etc.)
Expected behaviour
Start the server from RStudio using commands:
ff64 = "c:/PROGRAMS/Firefox/FirefoxPortable/App/Firefox64/firefox.exe"
rS <- rsDriver(browser = "firefox", port = 4565L, extraCapabilities = list(ff64))
rDr <- rS[['client']]
Actual behaviour
error message:
[1] "Connecting to remote server"
Selenium message:connection refused
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'MANIFOLD-4', ip: '192.168.184.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_192'
Driver info: driver.version: unknown
remote stacktrace:
Could not open firefox browser.
Client error message:
Summary: UnknownError
Detail: An unknown server-side error occurred while processing the command.
Further Details: run errorDetails method
Check server log for further details.
Steps to reproduce the behaviour
Use above code.
The problem is this stops working every few weeks. It usually happens when RSelenium download new drivers. It would work if I could disable this.
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking chromedriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
Creating directory: C:\Users\cp\AppData\Local\binman\binman_chromedriver\win32\2.45
Downloading binary: https://www.googleapis.com/download/storage/v1/b/chromedriver/o/2.45%2Fchromedriver_win32.z...
Creating directory: C:\Users\cp\AppData\Local\binman\binman_chromedriver\win32\72.0.3626.7
Downloading binary: https://www.googleapis.com/download/storage/v1/b/chromedriver/o/72.0.3626.7%2Fchromedriver_...
Creating directory: C:\Users\cp\AppData\Local\binman\binman_chromedriver\win32\71.0.3578.80
Downloading binary: https://www.googleapis.com/download/storage/v1/b/chromedriver/o/71.0.3578.80%2Fchromedriver...
BEGIN: POSTDOWNLOAD
checking geckodriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking phantomjs versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
I'm not sure how to deal with it.
I have used chrome for RSelenium. So below is for chrome, but probably could be used for firefox in a similar fashion. It is a version of the answer given here
library(binman)
library(stringr)
library(dplyr)
chromeversion <- toString(dir(path = 'C:/Program Files (x86)/Google/Chrome/Application/')) %>%
str_extract(., '^\\d+\\.\\d+\\.\\d+\\.') %>%
str_replace_all(., '\\.', '\\\\.')
chromedriver <- str_extract_all(toString(list_versions("chromedriver")), paste0(chromeversion, '\\d+'), simplify = TRUE) %>%
as.numeric_version(.) %>%
min(.)
In order of appearance:
-
chromeversion:
- Create a string path to the chrome application folder. There is a folder there that contains the version number.
- String extract the version number on that folder
- Replace all dots with a \\. (you need another backslash to escape the backslash) to use it in the next str_extract.
-
chromedriver:
- string extract all the matches of the object chromeversion added with another digit
paste0(chromeversions, '\\d+')
from the string resulting fromlist_versions("chromedriver)
(this is a binman function) - convert to numeric versions
- get the lowest version
min()
or alternatively the highest usingmax()
- string extract all the matches of the object chromeversion added with another digit
Now you can start chrome:
library(RSelenium)
rD1 <- rsDriver(browser = "chrome", port = 4567L, geckover = NULL,
chromever = toString(chromedriver), iedrver = NULL,
phantomver = NULL, verbose = TRUE, extraCapabilities = eCaps)
remDr1 <- rD1[["client"]]
Note that the chromever requires a string to be input, hence the toString(chromedriver).
library(RSelenium)
driver <- rsDriver(port=4444L,browser="chrome")
remote_driver <- driver$client
refer from https://github.com/ropensci/RSelenium/issues/203#issue-443871504 this work~
update: please see the great work of salim-b at #237 for proper detection of chrome driver