2016-12-19 16:39:29 +00:00
|
|
|
# Selenium tests
|
|
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
## Getting started
|
|
|
|
|
|
2024-02-15 13:46:21 +00:00
|
|
|
See <https://www.mediawiki.org/wiki/Selenium> for how to best
|
2019-09-20 17:37:36 +00:00
|
|
|
run these locally. Below the internal prerequisites are documented,
|
|
|
|
|
but you might not need to install these yourself.
|
|
|
|
|
|
2016-12-19 16:39:29 +00:00
|
|
|
## Prerequisites
|
|
|
|
|
|
2024-02-15 13:46:21 +00:00
|
|
|
- [Chromium](https://www.chromium.org/Home) or [Chrome](https://www.google.com/chrome)
|
|
|
|
|
- [Node.js](https://nodejs.org)
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
## Usage
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
There are three supported modes of running the tests.
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
#### Headless
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
The Selenium tests default to headless mode, unless a `DISPLAY` environment variable is set.
|
|
|
|
|
This variable may be set on Linux desktop and XQuartz environments. To run headless there,
|
|
|
|
|
unset the `DISPLAY` environment variable first.
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2024-02-16 12:33:43 +00:00
|
|
|
npm run selenium-test
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
Or:
|
2018-03-30 16:42:04 +00:00
|
|
|
|
2024-02-16 12:33:43 +00:00
|
|
|
DISPLAY= npm run selenium-test
|
2018-03-30 16:42:04 +00:00
|
|
|
|
2024-02-16 12:33:43 +00:00
|
|
|
### Visible browser
|
2018-03-30 16:42:04 +00:00
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
To see the browser window, ensure the `DISPLAY` variable is set. On Linux desktop and in XQuartz
|
|
|
|
|
environments this is probably set already. On macOS, set it to a dummy value like `1`.
|
2017-06-09 13:40:31 +00:00
|
|
|
|
2024-02-16 12:33:43 +00:00
|
|
|
DISPLAY=1 npm run selenium-test
|
2017-06-09 13:40:31 +00:00
|
|
|
|
2024-02-16 12:33:43 +00:00
|
|
|
### Video recording
|
2019-09-20 17:37:36 +00:00
|
|
|
|
2021-05-06 17:54:28 +00:00
|
|
|
To capture a video, the tests have to run in the context of an X11 server, with the `DISPLAY`
|
|
|
|
|
environment variable set to its display name. If the shell has no X11 server or if you want
|
|
|
|
|
to hide the output, you can also launch a virtual X11 display using Xvfb. Recording videos
|
|
|
|
|
is currently supported only on Linux, and is triggered by the `DISPLAY` value starting with
|
|
|
|
|
a colon (as Xvfb typically would).
|
|
|
|
|
|
|
|
|
|
Example test run in [Fresh](https://gerrit.wikimedia.org/g/fresh).
|
|
|
|
|
|
|
|
|
|
fresh-node -env -net
|
|
|
|
|
export DISPLAY=:1
|
2022-10-25 12:50:38 +00:00
|
|
|
Xvfb "$DISPLAY" -screen 0 1280x1024x24 &
|
2021-05-06 17:54:28 +00:00
|
|
|
npm run selenium-test
|
2018-01-13 11:52:26 +00:00
|
|
|
|
2024-02-16 12:33:43 +00:00
|
|
|
## Filter
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
Run a specific spec:
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2024-02-16 12:33:43 +00:00
|
|
|
npm run selenium-test -- --spec tests/selenium/specs/page.js
|
2017-11-28 13:26:42 +00:00
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
To filter by test case, e.g. with the name containing "preferences":
|
2017-11-28 13:26:42 +00:00
|
|
|
|
2024-02-16 12:33:43 +00:00
|
|
|
npm run selenium-test -- --mochaOpts.grep preferences
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2024-02-16 12:33:43 +00:00
|
|
|
## Configuration
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
The following environment variables decide where to find MediaWiki and how to login:
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2019-09-20 17:37:36 +00:00
|
|
|
- `MW_SERVER`: The value of `$wgServer`.
|
|
|
|
|
- `MW_SCRIPT_PATH`: The value of `$wgScriptPath`.
|
|
|
|
|
- `MEDIAWIKI_USER`: Username of a wiki account with sysop rights.
|
|
|
|
|
- `MEDIAWIKI_PASSWORD`: Password for this user.
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2018-05-02 17:48:24 +00:00
|
|
|
## Further reading
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2024-02-15 13:46:21 +00:00
|
|
|
- [Selenium](https://www.mediawiki.org/wiki/Selenium) on mediawiki.org
|