Mediawiki::Selenium

Several MediaWiki extensions share code that makes it easy to run Selenium tests. This gem makes it easy to update the shared code.

Installation

To run the Selenium tests you will have to install Ruby. Look at the Gemfile file for the exact required version. You also have to install the latest versions of RubyGems and Firefox (the default browser in which the tests run). The easiest way to install Ruby on Linux/Unix/Mac is RVM and on Windows RubyInstaller. ALERT: On Windows you must use Ruby 1.9.3 for now because cucumber/gherkin library currently doesn't work with Ruby 2.x.x.

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

If you're not using RVM to manage your Ruby versions, you will need to run the commands as root (using sudo).

Environment variables MEDIAWIKI_USER and MEDIAWIKI_PASSWORD are required for tests tagged @login. For local testing, create a test user on your local wiki and export the user and password as the values for those variables. For example:

export MEDIAWIKI_USER=<username here> # Linux/Unix/Mac
set MEDIAWIKI_USER=<username here> # Windows

export MEDIAWIKI_PASSWORD=<password here> # Linux/Unix/Mac
set MEDIAWIKI_PASSWORD=<password here> # Windows

Usage

Run the tests with bundle exec cucumber, this should start Firefox.

By default the tests run at en.wikipedia.beta.wmflabs.org. If you want to run the tests elsewhere, set the MEDIAWIKI_URL environment variable. For example:

export MEDIAWIKI_URL=http://commons.wikimedia.beta.wmflabs.org/wiki/ # Linux/Unix/Mac
set MEDIAWIKI_URL=http://commons.wikimedia.beta.wmflabs.org/wiki/ # Windows

To run a single test file enter bundle exec cucumber features/FEATURE_NAME.feature.

To run a single test scenario, put a colon and the line number (NN) on which the scenario begins after the file name: bundle exec cucumber features/FEATURE_NAME.feature:NN.

You can use a different browser with the BROWSER_LABEL env variable, the fastest is probably PhantomJS, a headless browser:

export BROWSER_LABEL=phantomjs # Linux/Unix/Mac
set BROWSER_LABEL=phantomjs # Windows

By default, the browser will close itself at the end of every scenario. If you want the browser to stay open, set the environment variable KEEP_BROWSER_OPEN to true:

export KEEP_BROWSER_OPEN=true # Linux/Unix/Mac
set KEEP_BROWSER_OPEN=true # Windows

mediawiki-selenium gem: Gerrit, GitHub, RubyGems, Code Climate

Repositories that use the gem:

  1. CirrusSearch: Gerrit, GitHub, Code Climate, /tests/browser folder
  2. ContentTranslation: Gerrit, GitHub, Code Climate, /tests/browser folder
  3. Flow: Gerrit, GitHub, Jenkins, Code Climate, /tests/browser folder
  4. MobileFrontend: Gerrit, GitHub, Jenkins, Code Climate, /tests/browser folder
  5. MultimediaViewer: Gerrit, GitHub, Jenkins, Code Climate, /tests/browser folder
  6. Translate: Gerrit, GitHub, Jenkins, Code Climate, /tests/browser folder
  7. TwnMainPage: Gerrit, GitHub, Jenkins, Code Climate, /tests/browser folder
  8. UniversalLanguageSelector: Gerrit, GitHub, Jenkins, Code Climate, /tests/browser folder
  9. VisualEditor: Gerrit, GitHub, Jenkins, Code Climate, /modules/ve-mw/test/browser folder
  10. Wikibase: Gerrit, GitHub, Jenkins, Code Climate, /tests/browser folder
  11. browsertests: Gerrit, GitHub, Jenkins, Code Climate, / folder

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

https://www.mediawiki.org/wiki/QA/Browser_testing#How_to_contribute