0

I am simply trying to launch a driver with RSelenium with the following code. The code worked fine a few weeks ago and now it's throwing an errror:

library(RSelenium)
library(rvest)
library(tidyverse)

driver <- rsDriver(port = 4845L, browser = "chrome", version = "3.141.59")
remdriv <- driver$client

The error is this:

checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking chromedriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking geckodriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking phantomjs versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
Warning: Could not determine server status.[1] "Connecting to remote server"
Could not open chrome browser.
Client error message:
Undefined error in httr call. httr output: Failed to connect to localhost port 4845: Connection refused
Check server log for further details.

I have then gone on to run the following code:

library(wdman)
selServ <- wdman::selenium(verbose = FALSE)
selServ$log()

Which told me that:

$stderr
[1] "Error: Could not find or load main class c(-Dwebdriver.chrome.driver=\"C:\\\\Users\\\\Name\\\\AppData\\\\Local\\\\binman\\\\binman_chromedriver\\\\win32\\\\109.0.5414.25.chromedriver.exe\","    
[2] "Caused by: java.lang.ClassNotFoundException: c(-Dwebdriver.chrome.driver=\"C:\\\\Users\\\\Name\\\\AppData\\\\Local\\\\binman\\\\binman_chromedriver\\\\win32\\\\109.0.5414.25.chromedriver.exe\","

$stdout
character(0)

I found the above on this post. But I'm not clear on what I need to do to fix the issue. If anyone has any ideas let me know. Thanks.

matt_lnrd
  • 329
  • 1
  • 9
  • 2
    There are lots of [rselenium connection refused](https://stackoverflow.com/search?q=rselenium+refused) problems out here. By the way, run `binman::list_versions("chromedriver")` and run rsDriver with `chromever=` option set to one of the listed above. Try also [this](https://stackoverflow.com/questions/74708282/rselenium-is-not-working-when-creating-servers) – Ric Jan 03 '23 at 02:30
  • 1
    @RicVillalba that worked! I had changed the version option, but hadn't tried chromever. Thanks! – matt_lnrd Jan 03 '23 at 13:59

1 Answers1

1

I was able to connect after using binman::list_versions("chromedriver") to list the chromedriver options and then used one of those within the driver call, so it now looks like this and opens the window:

driver <- rsDriver(port = 4842L, browser = "firefox", chromever = "102.0.5005.27")
remdriv <- driver$client

Thanks to @RicVillalba for the answer

matt_lnrd
  • 329
  • 1
  • 9