Selenium/Getting Started/Run tests targeting Beta cluster

For this example, we will target English Wikipedia at the Beta Cluster.

Advantages

edit
  • You do not have to install or learn how to use a local development environment like MediaWiki-Docker.
  • It will be reasonably fast. MediaWiki Core Selenium test run takes about 5 minutes on my machine. A lot of tests fail. Subset of passing tests takes about 1 minute. (As of September 2019.)
  • Debugging failed tests will be easier, since you are able to see the browser. See Selenium/How-to/Make the browser visible for more information.

Disadvantages

edit
  • You will need internet connection while running the tests.
  • The tests will be slower since the target machine is not local.
  • You will have to install Selenium and it's dependencies on your machine.

Clone MediaWiki Core

edit

There are several ways to clone the MediaWiki Core (anonymous http, http, ssh). In this example, will use anonymous http since it is the simplest. You can skip this step if you already have MediaWiki Core cloned.

git clone "https://gerrit.wikimedia.org/r/mediawiki/core"

Go to MediaWiki Core folder

edit
cd core

Install dependencies

edit

Depending on your operating system, installing dependencies will be different.

Browser

edit

Node.js

edit
  Warning: Running npm ci is not safe. See How to protect yourself from npm.
npm ci

Environment variables

edit

DISPLAY

edit

Check if DISPLAY environment variable is set with echo $DISPLAY. If there's no output, that's good. (The default on macOS). If you get any output, for example :0 (the default on Ubuntu Linux), unset the variable with unset DISPLAY.

For more information see Selenium/How-to/Make the browser visible and Selenium/How-to/Record videos of test runs.

MW_* and MEDIAWIKI_*

edit

Ensure the following environment variables are set. Either run this manually from the terminal or, to make it easier for next time, set them from shell configuration file (~/.bash_profile, ~/.zshrc...) which means the variables are always available from any terminal session:

# Target Beta cluster
export MW_SERVER=https://en.wikipedia.beta.wmflabs.org
export MW_SCRIPT_PATH=/w
export MEDIAWIKI_USER=mediawiki_user
export MEDIAWIKI_PASSWORD=mediawiki_password

If you prefer, you can create an .env file instead (in MediaWiki Core folder), with this contents.

# Target Beta cluster
MW_SERVER=https://en.wikipedia.beta.wmflabs.org
MW_SCRIPT_PATH=/w
MEDIAWIKI_USER=mediawiki_user
MEDIAWIKI_PASSWORD=mediawiki_password

Replace mediawiki_user and mediawiki_password with your username and password.

Run the Selenium tests

edit

Run all tests.

npm run selenium-test

Please note that a lot of tests will fail. Tests are written for targeting MediaWiki on a Jenkins worker machine and MediaWiki-Docker.

If you would like to run a subset of passing tests, run this.

npm run selenium-daily