Orange County R Users Group (OC-RUG): RSelenium Webinar

Yesterday I gave a webinar on the Rselenium package to the OC-RUG. When I published RSelenium on CRAN Ray DiGiacomo the president of OC-RUG was kind enough to invite me to present RSelenium and that webinar was held on the 21st of May. I would like to thank OC-RUG and Ray in particular for the opportunity.

I will use this blog to present the video of the webinar and also for a bit of bookkeeeping. Firstly I would like to return to two of the questions asked in the Q&A.

Q&A question 2 and 3

How would you save a screenshot to file using RSelenium?

In the seminar I suggested that the Selenium webdriver returned the png in a base 64 encoded format. I tried to save the output to file using writeBin and remarked that I probably needed to decode the output. So here is what I should have done:

b64out <- remDr$screenshot() writeBin(base64Decode(b64out, "raw"), 'nameoffile.png')

How would you use a chrome profile?

In the seminar I remarked that the google chrome browser had hundreds of startup options. They are actually termed command line switches. The two I was after were --user-data-dir and --profile-directory. It would then have been sufficient to use:

``` args = list(paste0(‘–user-data-dir=’,dataDir) , paste0(‘–profile-directory=’,profileDir)) cprof <- list(chromeOptions = list(args = args)) remDr <- remoteDriver(browserName = ‘chrome’, extraCapabilities = cprof)

### Added to RSelenium

I added the above functionality to RSelenium. So now the `screenshot` method of the `remoteDriver` class has an optional `file` argument. If `display` is `FALSE` and a `file` argument is given `RSelenium` will now save the `png` to file. 

Secondly there is now a `getChromeProfile` utility function in a similar vein to the existing getFirefoxProfile function. The function is documented in the RSelenium package. Its basic usage is as follows:
# example from windows using a profile directory "Profile 1"
dataDir <- "C:\\Users\\john\\AppData\\Local\\Google\\Chrome\\User Data"
cprof <- getChromeProfile(dataDir, "Profile 1")
remDr <- remoteDriver(browserName = "chrome", extraCapabilities = cprof)

So it takes two arguments: a users chrome data directory and the profile directory within that data directory from which you want to run.

I will update the version of RSelenium on CRAN in the coming weeks. If you would like to run the dev version with added features you can install it with:


and remember to file any issues you may have. to github so RSelenium can improve as a package :).

The webinar screencast

SauceLabs test results

At the end of the webinar the simple test on the shinytestapp was ran against multiple OS and browsers using Sauce Labs as an external provider for the selenium server and the browsers. These test results can be seen bu navigating to the RSelenium Sauce Labs page and searching for OCRUG TEST 1 in the search session name panel.

The directors cut

I have shot an extended version of the webinar with the fabled missing javascript example which follows:

The slides and R scripts.

And finally I have posted the slides for the webinar to github. Please find them at There are also some R scripts contained in the master branch of the github project .


Hopefully that ties up any loose ends. It was great fun preparing the webinar. I enjoyed giving it and I’m gratefully to everyone who attended.