wiki.techinc.nl/tests/selenium
Timo Tijhof 6143f757ea selenium: Replace wdio-chromedriver with ./selenium.sh script
This package was serving two purposes:

* Install chromedriver automatically.
* Start chromedriver automatically when using the
  'npm run selenium' entry point (e.g. for local development).

For the CI entry points (selenium-test, selenium-daily) the
chromedriver is skipped. For those, we expect the CI runner to
have started a chromedriver server already, which allows the
server to continue running between different the test suites
of different extensions etc.

By letting WDIO start the chromedriver for local development,
we had the benefit of 'npm run selenium' directly being an alias
to the 'wdio' command. This made it easy to pass additional
arguments like --spec or --mochaOpts for running specific tests
only and overall makes things easier to reason about from a
developer perspective with fewer (required) layers of
indirection you see and need to understand when debugging.

But, this has also caused problems. Specifically, it means
developers have to use the same version of Chrome locally
as we specify in package.json which isn't very flexible. While
we could try to keep this up-to-date roughly, that too isn't
an option because the secure environments we recommend for local
use (Quibble and Fresh-node) both use a Debian distro with
typically older versions of Chromium than your local auto-updating
Google Chrome.

For now, let's go back to moving the responsibility of installing
chromedriver together with the responsibility to install Chrome
itself.

== Changes ==

For CI, nothing changes (it already installs both).

For developers using Quibble, Vagrant or Fresh nothing changes
(already installs both).

For developers who make their own secure environment, they will
need to make sure chromedriver is installed, just as we required
between 2017 and Aug 2019 before my commit 1955a8aa56.

== How ==

wdio-chromedriver cannot start a foreign install because the
protocol can change between versions, so unfortunately together
with not using chromedriver from npm, we also can't use
the wdio-chromedriver autostart mechanism. Instead, I'm bringing
back Antoine's shell script that did this prior to ebda397c54.
But, with a few tweaks so that it forwards shell arguments,
this way developers continue to enjoy the benefit of 1955a8aa56,
which is that 'npm run selenium -- --spec foo.js' works.

Bug: T234610
Change-Id: I03ca94315d0611d2b6abccc12cf9076d41b2c00e
2020-01-17 17:03:54 +00:00
..
pageobjects selenium: Fix more inefficient MWBot use and simplify wdio-mediawiki Api 2019-10-04 18:16:28 +01:00
specs Disable flaky Selenium test 2019-10-08 20:50:37 +00:00
wdio-mediawiki wdio-mediawiki: Release 1.0.0 2019-11-05 14:47:48 -05:00
.eslintrc.json eslint: Use correct global values, and use jquery rules in selenium tests 2019-10-08 13:12:17 +01:00
README.md selenium: Replace wdio-chromedriver with ./selenium.sh script 2020-01-17 17:03:54 +00:00
selenium.sh selenium: Replace wdio-chromedriver with ./selenium.sh script 2020-01-17 17:03:54 +00:00
wdio.conf.js selenium: Replace wdio-chromedriver with ./selenium.sh script 2020-01-17 17:03:54 +00: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). For example:

DISPLAY=:2 npm run selenium

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