wiki.techinc.nl/tests/selenium
Željko Filipin 4a657ec634 selenium: Fix failing selenium-daily-beta(commons)-MediaWiki Jenkins job
The jobs are running a subset of tests. (Tests containing string
`@daily` in  the name.) To find the tests we are using
`--mochaOpts.grep` WebdriverIO command line option. The filter is
executed after the tests have already started. Since some test files
have no tests with string `@daily`, they are skipped. That results in
JUnit reporter creating a couple of empty XML files. Jenkins thinks
empty files are failures and fails the build.

This commit creates a suite of files that have tests with string
`@daily` and runs only those files.

Bug: T281505
Change-Id: Id844da81feac49f2a2b6820e98ead98d7e932e9f
2021-04-30 13:42:20 +02:00
..
pageobjects Merge "selenium: Tests pass if Vector skin is not installed" 2021-03-09 20:22:46 +00:00
specs selenium: Delete tests disabled for more than 1 year 2021-04-23 13:25:59 +02:00
wdio-mediawiki selenium: Add timestamp to screenshot file name 2021-04-28 21:08:56 +00:00
.eslintrc.json eslint: Update to eslint-config-wikimedia 0.16.0 2020-06-02 21:32:56 +01:00
README.md Selenium: Use wdio-video-reporter for recording test videos 2020-06-15 13:32:02 +02:00
wdio.conf.js selenium: Fix failing selenium-daily-beta(commons)-MediaWiki Jenkins job 2021-04-30 13:42:20 +02: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

wdio-video-reporter is used to record videos. All videos will be stored by default in the tests/selenium/log directory. This can be overridden by setting the LOG_DIR environment variable. To record videos only for failed tests, set the saveAllVideos = false in tests/selenium/wdio.conf.js file.

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