Ask for latest compatible driver?
Please fill the following template:
Operating System:
MacOS 10.13.6
Please describe Expected behaviour
I'm trying to use RSelenium to drive Google Chrome. For a long time I've had chromever="latest"
in the RSelenium::rsDriver call; it passes the version to wdman::selenium, and that opens the driver.
Please describe Actual behaviour
Today the latest Chrome driver is 74.0.3729.6, which doesn't work with my Chrome 73.0.3683.75, so the rsDriver call fails. Here's what I see:
> RSelenium::rsDriver(verbose = TRUE,
+ port = 4567L,
+ chromever="latest",
+ geckover = NULL,
+ phantomver = NULL)
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking chromedriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
[1] "Connecting to remote server"
Selenium message:session not created: This version of ChromeDriver only supports Chrome version 74
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Mac OS X 10.13.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.16 seconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'djmair3.local', ip: 'fe80:0:0:0:86b:ea4d:a09e:1599%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_71'
Driver info: driver.version: unknown
Could not open chrome browser.
Client error message:
Summary: SessionNotCreatedException
Detail: A new session could not be created.
Further Details: run errorDetails method
Check server log for further details.
$client
[1] "No sessionInfo. Client browser is mostly likely not opened."
$server
Process Handle
command : /private/var/folders/d6/s97fjjxd3_9353x_lwb692100000gn/T/RtmpDGdXRU/file606c956632.sh
system id : 1563
state : running
Is there some way to say "the latest compatible version" instead of the "latest"?
Steps to reproduce the behaviour
I think the only thing necessary is to try to open the latest chromedriver on a system that doesn't have Chrome 74.x.
There isn't an automated way to do that yet, but you can list available chrome drivers and manually pass the compatible version to chromever in rsDriver().
> binman::list_versions("chromedriver")
$win32
[1] "73.0.3683.20" "73.0.3683.68" "74.0.3729.6"
> rs <- RSelenium::rsDriver(chromever = "73.0.3683.68")
There isn't an automated way to do that yet
I've written some logic a while ago that automatically determines the latest ChromeDriver version compatible with the stable Chrome binary of your system, see https://github.com/ropensci/RSelenium/issues/221. It should work on Linux, macOS and Windows.
I'd be happy to revise that code (for example we shouldn't rely on binman::list_versions() since it just returns an error in the case of a fresh install where no ChromeDriver versions had been downloaded before and instead parse https://chromedriver.storage.googleapis.com/index.html directly) and submit a PR if you could provide some guidance.
I resorted to this code inside r, to download the latest driver automatically. This works for Linux. You need wget and 7z installed on your system
library(rvest) library(tidyverse)
chrome_driver_url <- read_html("https://googlechromelabs.github.io/chrome-for-testing") |> html_elements("table") |> html_table()
chrome_driver_url <- chrome_driver_url[[2]] |> filter(Binary == "chromedriver", Platform == "linux64") |> pull(URL)
directory_path <- "$HOME/.local/share/binman_chromedriver/linux64/" version <- str_replace(chrome_driver_url, ".+/([\d\.]+)/.+", "\1") folder_path <- paste0(directory_path, version) system(paste("mkdir -p", folder_path)) system(paste0("wget -O ", folder_path, "/chromedriver_linux64.zip ", chrome_driver_url)) system(paste0("7z e ", folder_path, "/chromedriver_linux64.zip -o", folder_path)) system(paste("find", shQuote(directory_path), "-type f -name 'LICENSE.chromedriver' -exec rm {} \;"))