Selenium/How-to/Run tests targeting Patch demo
For this example, we will target the public instance of Patch demo. To access Patch Demo you need a Wikimedia account. Using Patch Demo, you can choose which extensions and patches you need using the GUI.
Clone MediaWiki core
[edit]There are several ways to clone the MediaWiki core (anonymous http, http, ssh). In this example, we 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]- Install Google Chrome or Chromium.
Node.js
[edit]- Install Node.js and npm.
- Install required npm packages.
npm ci
Start Patch demo
[edit]- Go to Patch demo in your browser
- Create a wiki with the patches/extensions you need for your test and click "Create demo"
- Patch demo will show usernames and passwords for the users. Save those to use in your environment variables.

- In the last step when you press "Open wiki" you will get the URL to your instance (it will look something like
https://651d9fcf78.catalyst.wmcloud.org. Use that instead ofpatchdemo_urlwhen you configure yourMW_SERVERin the next step.
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 Patch Demo
export MW_SERVER=patchdemo_url
export MW_SCRIPT_PATH=/w
export MEDIAWIKI_USER="Patch Demo"
export MEDIAWIKI_PASSWORD=patchdemo1
If you prefer, you can create an .env file instead (in MediaWiki core folder), with this content.
# Target Patch Demo
MW_SERVER=patchdemo_url
MW_SCRIPT_PATH=/w
MEDIAWIKI_USER="Patch Demo"
MEDIAWIKI_PASSWORD=patchdemo1
Replace patchdemo_url with your url that you will get when you create your Patch demo instance.
Run the Selenium tests
[edit]Run all tests.
npm run selenium-test
At the moment some test fails, that is tracked in phab:T403156. |
