Selenium/Ruby/Setup instructions

Setup
Please setup either a virtual machine or your computer for browser testing.

User
Create an account on beta labs if you don't already have one.

Git
Create Gerrit account. Creating GitHub accounts is optional, but recommended.

On Mac install GitHub for Mac. Run the Github app and at Configure Git step of the startup wizard click Install Command Line Tools button.

On Ubuntu install it with.

On Windows install GitHub for Windows. After the installation Git Shell shortcut will appear on your desktop. Clicking the shortcut will open command line with Git configured.

Setup virtual machine
Tested on OS X 10.8.4 and Ubuntu 13.04 64-bit.

The easiest way to set everything up is to use MediaWiki-Vagrant virtual machine.

If you have Git installed, follow the instructions in Quick start section. If you do not have Git installed (instead of  step) get the code from wikimedia/mediawiki-vagrant Github repository, just click Download ZIP button.

In addition to the instructions there, on OS X you will need to install the latest version of XQuartz

Run  to see the available roles then use   command to enable the   role. This will set up Ruby and check out the browsertests for "core" MediaWiki features.

Now run  to boot the virtual machine

Then run. Access the virtual machine with. The browser tests for "core" MediaWiki features will be in.

Example of setting up vagrant in Terminal:

$ git clone https://gerrit.wikimedia.org/r/mediawiki/vagrant $ cd vagrant $ vagrant enable-role browsertests $ vagrant up $ vagrant provision $ vagrant ssh -- -X $ cd /srv/browsertests

Browser
Install Firefox (if you do not already have it installed).

Ruby on Windows
Tested on Windows 7 Enterprise, Service Pack 1, 32-bit.

Download Ruby 1.9.3-p429 and DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe from RubyInstaller.

Install Ruby. You can leave all settings at default values, except at the Installation Destination and Optional Tasks screen check Add Ruby executables to your PATH checkbox.

Extract DevKit to  and set it up from Command Prompt:

C:\>cd devkit

C:\devkit>ruby dk.rb init [INFO] found RubyInstaller v1.9.3 at C:/Ruby193

Initialization complete! Please review and modify the auto-generated 'config.yml' file to ensure it contains the root directories to all of the installed Rubies you want enhanced by the DevKit.

C:\devkit>ruby dk.rb install [INFO] Updating convenience notice gem override for 'C:/Ruby193' [INFO] Installing 'C:/Ruby193/lib/ruby/site_ruby/devkit.rb'

Ruby on Mac
Tested on OS X 10.8.4.

Mac machines come with Ruby installed, but unfortunately, it is an old version (1.8.7). To run the tests you will need a more recent version of Ruby (1.9.3 or 2.0).

Download and install Command Line Tools (OS X Mountain Lion) for Xcode - April 2013 from developer.apple.com.

Install Ruby Version Manager (RVM) by running this in Terminal.

Open a new Terminal window or tab and install Ruby:

Ruby on Linux
Tested on Ubuntu 13.04 64-bit.

Install Ruby Version Manager (RVM) by running this in Terminal.

Installing rvm configures your shell to add rvm commands and check the current directory's ruby version, but there are glitches in getting this to happen automatically described below. For now, enter source ~/.rvm/scripts/rvm, then change to the directory with browser tests in it (it has a file named Gemfile). This should prompt you to install the version of ruby mentioned in the Gemfile (as of January 2014 most tests use ruby 2.1.0).

For example:

rvm initialization
rvm installation adds commands to automatically configure ruby based on your current directory, but getting this to happen can be tricky. If it's working, then entering rvm current in the directory with tests should print something like ruby-2.1.0@browsertests.
 * To configure Gnome/Ubuntu Terminal to work with RVM, choose Terminal > Edit > Profile Preferences > Title and Command > Run command as a login shell > check close. For more information see Integrating RVM with gnome-terminal.
 * In every terminal application, you must open a new terminal window or tab for the changes to take effect.
 * If rvm still doesn't automatically enforce the current directory's ruby version, then before running browser tests you may need to enter source ~/.rvm/scripts/rvm to use RVM properly. You can add this to your shell environment if you find yourself using it constantly.

Code
Clone qa/browsertests Gerrit repository.

Install required Ruby software
Open Terminal (Mac, Linux) or Command Prompt (Windows) application and type this. is the name of the folder where the code is located.

$ cd browsertests/tests/browser $ gem update --system $ gem install bundler $ bundle install

If there is error encountered during bundle install such as individual package failed to install, try the following:

$ sudo aptitude purge ruby1.8 $ gem install bundler $ bundle install

Setup for testing with other browsers
It is possible to run tests with other browsers(Chrome, PhantomJS) by exporting BROWSER environment variable.


 * Chrome
 * Install Chrome
 * Install ChromeDriver
 * PhantomJS
 * Install PhantomJS

Getting help
Discussion is always welcome on the IRC channel #wikimedia-qa on freenode. Also, the QA mail list welcomes subscribers.