Jason Gowan

Selenium Standalone On Docker

We will setup selenium standalone server on a docker image.

There are two major limitations to running automation tests locally. Browsers will steal focus preventing you from working on other stuff when the tests are running. Your browser version and OS are normally different from what the selenium grid is running. A docker image will allow us to run on the same OS and browser version. The tests will be viewed in vnc without the browser stealing focus.

Setup

Install docker and start the docker service.

Build the docker image from github.

git clone https://github.com/jesg/docker-selenium-grid.git
cd docker-selenium-grid/standalone-server
sudo docker build -t local/standalone-server .

Start Selenium Server

Run the docker image

sudo docker run -p 4444:4444 -p 5910:5910 -t local/standalone-server

Install the watir-webdriver gem.

gem install watir-webdriver

Open vncviewer to port 5910 (hint: password is 123456)

vncviewer localhost::5910

Run a small ruby script that opens a browser

require 'watir-webdriver'

browser = Watir::Browser.new(
  :remote, 
  :url => "http://127.0.0.1:4444/wd/hub",
  :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.firefox)

browser.goto 'http://google.com'
puts browser.title
browser.quit