from RSelenium vignette, RPubs, and Docker GitHub

RSelenium moved to using Docker, which allows to standardize package behavior across operating systems, and therefore remove all concomitant issues.

Download and Install

  1. Docker, an environment to run Selenium server.
  2. TightVNC, a viewer to observe the result of RSelenium navigation commands.

Setup Docker to work with Selenium

  1. Enable hardware virtualization. It is sufficient to enable it in BIOS, and subsequent steps are unnecessary. If you don’t have it enabled, Docker will throw the following error:
    This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory.
    
  2. Save this json file as latest.json into /Users/{user}/.docker/machine/cache/.
    Upon starting, Docker will download boot2docker.iso.
    Without it, you most likely will see the following error upon Docker launch:
    No default Boot2Docker ISO found locally, downloading the latest release...
    
  3. Start Docker Quickstart Terminal. You should see a console prompt similar to this one:
    Docker Console

  4. In Docker Terminal run the following commands:
    $ docker pull selenium/standalone-chrome
    $ docker run -d -p 4445:4444 selenium/standalone-chrome
    

    A full list of Selenium Docker images is available here.

  5. Alternatively, for debug mode (to enable viewing results of RSelenium navigation) use:
    $ docker pull selenium/standalone-chrome-debug
    $ docker run -d -p 5901:5900 -p 4445:4444 selenium/standalone-chrome-debug
    

    Then start the TightVNC.
    In the prompt, enter 192.168.99.100:5901 as Remote Host: and click Connect.
    In the next window enter secret as Password:.
    The result of all RSelenium navigation commands can be seen in this window.

Connect R Session to Selenium Server

In R, create a remoteDriver object, and navigate to a desired url:

#load RSelenium package
require(RSelenium)
#point to the remote server
remDr<- 
       remoteDriver(remoteServerAddr = "192.168.99.100" 
                    , port = 4445L 
                    , browserName = "chrome"
					)
#navigate to url
remDr$open()
remDr$navigate("https://www.google.com/")