# 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 bookkeeping. 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 start up 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)


I add 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"
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:

devtools::install_github("johndharrison/RSelenium")

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

## 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 http://johndharrison.github.io/RSOCRUG. There are also some R scripts contained in the master branch of the github project https://github.com/johndharrison/RSOCRUG .

## Conclusion

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

## Saturday, 29 March 2014

### RStudio/Shiny server on digital ocean fuelled by hot chocolate and a kit-kat chunky

RStudio/Shiny server on digital ocean fuelled by hot chocolate and a kit-kat chunky

# Introduction

A number of people had told me about digitalocean recently so when a new project came along I decided to try it out. Digital Ocean I had gathered was a cloud hosting platform in the vein of amazon and co. I had used AWS previously so I was interested to see how this platform would compare.

## Setting up

Creating an account involved giving an email address and creating a password. After this an option was given to load credit onto the account. Paypal was accepted so I used this option to credit the account. After this I was taken to a basic screeen with a big green button labelled create. Seemed simple enough so I clicked it.

## Wednesday, 19 March 2014

### Installing RSelenium on Win 8.1

I was asked was it difficult to install and get RSelenium up and running on the windows platform.
It isn't and I made a quick screenr to show you how.

So in summary:

RSelenium basics

# RSelenium basics

## Introduction

The goal of RSelenium is to make it easy to connect to a Selenium Server/ Remote Selenium Server from within R. RSelenium provides R bindings for the Selenium Webdriver API. Selenium is a project focused on automating web browsers. RSelenium allows you to carry out unit testing and regression testing on your webapps and webpages across a range of browser/OS combinations. This allows us to integrate from within R testing and manipulation of popular projects such as shiny, sauceLabs.
This vignette is divided into six main sections:
Each section will be an introduction to a major idea in Selenium, and point to more detailed explanation in other vignettes.