Selenium/Getting Started/Run tests targeting MediaWiki-Docker
This page describes how to run Selenium tests locally on your development install of MediaWiki. This tutorial is based on the setup from MediaWiki-Docker.
Advantages
[edit]- It will be fast, since the target machine is local. MediaWiki core Selenium test run takes about 4 minutes on my machine. (As of September 2019.)
- Works without an internet connection.
Disadvantages
[edit]- You will have to install MediaWiki, Selenium and their dependencies on your machine.
- You will be executing over 900 JavaScript packages (as of August 2019) directly on your machine with access to all personal/work files.
Go to MediaWiki Core folder
[edit]cd core
Install dependencies
[edit]Depending on your operating system, installing dependencies will be different.
MediaWiki
[edit]- We assume you have a MediaWiki-Docker setup. It should be similar for other local MediaWiki installations.
Browser
[edit]- Install Google Chrome or Chromium.
Node.js
[edit]- Install Node.js and npm.
- Install required npm packages.
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 or hidden and Selenium/How-to/Record videos of test runs.
MW_*
and MEDIAWIKI_*
[edit]This is an optional step. Check if you have these environment variables already set in terminal (for example with env | sort
) or in .env
file (for example with cat .env
). If not, read on.
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 MediaWiki-Docker
export MW_SERVER=http://localhost:8080
export MW_SCRIPT_PATH=/w
export MEDIAWIKI_USER=Admin
export MEDIAWIKI_PASSWORD=dockerpass
Or create a .env
file at the root of the MediaWiki repository:
# Target MediaWiki-Docker
MW_SERVER=http://localhost:8080
MW_SCRIPT_PATH=/w
MEDIAWIKI_USER=Admin
MEDIAWIKI_PASSWORD=dockerpass
Run Selenium tests
[edit]npm run selenium-test