Search code examples
rweb-scrapingrseleniumrsdriver

RSelenium can't connect to host rsDriver()


Until recently, I was using RSelenium without any problem. When I try to connect to hostr rsDriver() to start a selenium server and browser, I get the following error message:

Could not open firefox browser.
Client error message:
Undefined error in httr call. httr output: Failed to connect to localhost port 5111: Connection refused
Check server log for further details.
Warning message:
In rsDriver(browser = "firefox", port = 5111L, verbose = F) :
  Could not determine server status.

I have looked at some answers already proposed, like in this page. However, when I run the command,

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

I get the following error message:

$stderr
[1] "Error: Could not find or load main class c(-Dwebdriver.chrome.driver="C:\\\\Users\\\\user\\\\AppData\\\\Local\\\\binman\\\\binman_chromedriver\\\\win32\\\\109.0.5414.25.chromedriver.exe\","
$stdout
character(0)

I tried to reinstall Java, but without success.


Solution

  • Ok I just solved the issue. The issue was that RSelenium recognises the chromedriver even when using other browsers so when the driver is not compatible to your current chrome version, it would have an issue with rsDriver. In order to solve this, you can either input NULL next to chromever or older chrome driver version from C:\Users\NAME\AppData\Local\binman\binman_chromedriver\win32

     rD <- rsDriver(port= sample(7600)[1], browser=c("firefox"), chromever = NULL)
    
     rD <- rsDriver(port= sample(7600)[1], browser=c("firefox"), chromever = 108.0.5359.22)