wiki.techinc.nl/tests/selenium
Željko Filipin aca6ae6d83 selenium: Use @wdio/spec-reporter
@wdio/dot-reporter that we currently use doesn't display much. For
example, it doesn't display skipped tests. It says 5 test suites are
executed, but that's a lie. 3 of those 5 suites are skipped.

@wdio/spec-reporter is more verbose but it actually outputs useful
information, like which tests are running, which are skipped.

This is a revert of aa7133ce86.

Bug: T280331
Change-Id: I7cef7d6a6d1b5e472622a81afc4f9a91523c1ca9
2022-03-24 15:31:45 +00:00
..
pageobjects [selenium] Remove leftovers from rollback tests 2022-01-27 16:23:16 +01:00
specs selenium: Refactor WebdriverIO tests from sync to async mode 2022-01-29 04:00:51 +11:00
wdio-mediawiki selenium: Use @wdio/spec-reporter 2022-03-24 15:31:45 +00:00
.eslintrc.json eslint: Update to eslint-config-wikimedia 0.16.0 2020-06-02 21:32:56 +01:00
README.md selenium: Record videos using Xvfb+ffmpeg 2021-05-20 15:46:20 +02:00
wdio.conf.js selenium: run 4 tests in parallel 2022-01-05 17:31:13 +01:00

Selenium tests

Getting started

See https://www.mediawiki.org/wiki/Selenium/Node.js for how to best run these locally. Below the internal prerequisites are documented, but you might not need to install these yourself.

Prerequisites

Usage

There are three supported modes of running the tests.

Headless

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.

npm run selenium

Or:

DISPLAY= npm run selenium

Visible browser

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.

DISPLAY=1 npm run selenium

Video recording

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.

fresh-node -env -net
export DISPLAY=:1
Xvfb "$DISPLAY" -screen 0 1280x1024x24 &
npm run selenium-test

Filter

Run a specific spec:

npm run selenium -- --spec tests/selenium/specs/page.js

To filter by test case, e.g. with the name containing "preferences":

npm run selenium -- --mochaOpts.grep preferences

Configuration

The following environment variables decide where to find MediaWiki and how to login:

  • 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.

Further reading