natedjurus
natedjurus

Reputation: 349

Connection refused error when attempting to use RSelenium chromedriver

I run

require(RSelenium)
driver <-
  rsDriver(
    browser = c("chrome"),
    chromever = "83.0.4103.14",
    port = as.integer(4445L)
 )

which returns

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
[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 1242: Connection refused
Check server log for further details.

I get the same problem attempting to use the remoteDriver function with docker:

system("sudo docker pull selenium/standalone-chrome",wait=T)
Sys.sleep(5)
system("sudo docker run -d -p 4445:4444 selenium/standalone-chrome",wait=T)
Sys.sleep(5)
#remDr <- remoteDriver(port=4445L, browserName="chrome")
remDr <- RSelenium::remoteDriver(remoteServerAddr = "192.168.99.100",
  port = 4445L, browserName = "chrome")
remDr$open()

It doesn't work for firefox, and up until now it has been working perfectly with the exact same code. Any help would be much appreciated (I've been through the other answers on this error message and can't find anything that fixes it).

Upvotes: 3

Views: 1343

Answers (1)

natedjurus
natedjurus

Reputation: 349

Finally solved this. If you run:

sel <- wdman::selenium()
sel$log()

it should show you any errors thrown up when trying to initialise selenium. In this case the path to the java binary was incorrect (no idea why it changed on its own).

So I simply re-followed the steps mentioned here: "PATH to JAVA not found. Please check JAVA is installed." error when initialising RSelenium

and it worked.

Upvotes: 1

Related Questions