2

I'm trying to connect to Selenium server using the most recent version of RSelenium. Here is the code I used:

install.packages('RSelenium')
library(RSelenium)
remDr <- remoteDriver(remoteServerAddr = "localhost" 
                      , port = 4445L
                      , browserName = "firefox"
)
remDr$open()

The output is as follows:

Error in checkError(res) : 
  Undefined error in httr call. httr output: Failed to connect to localhost port 4445: Connection refused

I have tried this solution (using the docker). I downloaded the docker from here (as I am using macOS 10.12.5) and added the executable to PATH. After running this code:

system('docker run -d -p 4445:4444 selenium/standalone-chrome')

I get this output:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

I have tried some other solutions but none of them worked. Can you help me please?

alistaire
  • 38,696
  • 4
  • 60
  • 94
AKheirallah
  • 21
  • 1
  • 5
  • It's a bit easier to use the included functions to run PhantomJS than Firefox/whatever. – alistaire Sep 03 '17 at 22:33
  • Give `splashr` a try — https://cran.r-project.org/web/packages/splashr/index.html & https://github.com/hrbrmstr/splashr. It's an alternative to the Selenium ecosystem based on http://splash.readthedocs.io/en/stable/ – hrbrmstr Sep 03 '17 at 23:47
  • Having said that, did you install Docker from https://www.docker.com/docker-mac and did you verify the Docker "hello world" example works before attempting to use Selenium? – hrbrmstr Sep 03 '17 at 23:48
  • 1
    Your docker daemon isn't running. No issue with selenium. May be docker needs sudo user privileges. Try that! – harshavmb Sep 04 '17 at 03:10

1 Answers1

1

You need administrator privileges to run a docker container, you can't do this inside an R Script unless it's run with administrator privileges. This goes for Windows or Mac users.

My recommendation is to run the command

docker run -d -p 4445:4444 selenium/standalone-chrome

inside a command-line shell you have opened with admin privileges.

Victor Burnett
  • 402
  • 4
  • 8