selenium: Improve README docs
Simplify the README to only mention the bare minimum about
how to use WDIO itself. The rest is deferred to the various wiki
pages, which are more up to date.
Also removes selenium.sh file, which is no longer used as of 1955a8aa56,
I forgot to re-remove it during one of the rebases.
It is now supported to pass arguments to 'npm run selenium' as well.
Previously, arguments were only supported for 'npm run selenium-test',
which required manual starting of a chromedriver.
Bug: T214708
Change-Id: I5951af9146ac5fdce8d6506d703620049d6efe74
This commit is contained in:
parent
da4d9b575f
commit
ebda397c54
2 changed files with 40 additions and 61 deletions
|
|
@ -1,74 +1,68 @@
|
|||
# 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
|
||||
|
||||
- [Chrome](https://www.google.com/chrome/)
|
||||
- [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/)
|
||||
- [Chromium](https://www.chromium.org/) or [Chrome](https://www.google.com/chrome/)
|
||||
- [Node.js](https://nodejs.org/en/)
|
||||
|
||||
If using MediaWiki-Vagrant:
|
||||
|
||||
cd mediawiki/vagrant
|
||||
vagrant up
|
||||
|
||||
## Installation
|
||||
|
||||
cd mediawiki
|
||||
npm install
|
||||
|
||||
## 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
|
||||
|
||||
There are three supported modes of running the tests:
|
||||
Or:
|
||||
|
||||
- Headless. It's the default. You will not see the browser while tests are
|
||||
running because it's running in a headless mode. This mode should run fine
|
||||
on all supported platforms.
|
||||
- Headless recording. Set DISPLAY environment variable to a value that starts
|
||||
with colon (`:`) and video of each test will be recorded. Browser will run
|
||||
headless. Recording videos works only on Linux.
|
||||
- Visible. If you want to see the browser, set DISPLAY environment variable to
|
||||
any value that does not start with colon. This mode will not work in a
|
||||
headless environment like MediaWiki-Vagrant.
|
||||
DISPLAY= npm run selenium
|
||||
|
||||
Example recording session:
|
||||
#### Visible browser
|
||||
|
||||
sudo apt-get install chromedriver ffmpeg xvfb
|
||||
export DISPLAY=:94
|
||||
Xvfb "$DISPLAY" -screen 0 1280x1024x24 &
|
||||
npm run selenium
|
||||
|
||||
Example visible session:
|
||||
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
|
||||
|
||||
To run only one test (for example specs/page.js), you first need to start Chromedriver:
|
||||
#### Video recording
|
||||
|
||||
chromedriver --url-base=wd/hub --port=4444
|
||||
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:
|
||||
|
||||
Then, in another terminal:
|
||||
DISPLAY=:2 npm run selenium
|
||||
|
||||
npm run selenium-test -- --spec tests/selenium/specs/page.js
|
||||
#### Filter
|
||||
|
||||
You can also filter specific cases, for ones that contain the string 'preferences':
|
||||
Run a specific spec:
|
||||
|
||||
npm run selenium-test -- tests/selenium/specs/user.js --mochaOpts.grep preferences
|
||||
npm run selenium -- --spec tests/selenium/specs/page.js
|
||||
|
||||
The runner reads the configuration from `wdio.conf.js`. The defaults target
|
||||
a MediaWiki-Vagrant installation on `http://127.0.0.1:8080` with a user "Admin"
|
||||
and password "vagrant". Those settings can be overridden using environment
|
||||
variables:
|
||||
To filter by test case, e.g. with the name containing "preferences":
|
||||
|
||||
- `MW_SERVER`: to be set to the value of your $wgServer
|
||||
- `MW_SCRIPT_PATH`: ditto with $wgScriptPath
|
||||
- `MEDIAWIKI_USER`: username of an account that can create users on the wiki
|
||||
- `MEDIAWIKI_PASSWORD`: password for above user
|
||||
npm run selenium -- --mochaOpts.grep preferences
|
||||
|
||||
Example:
|
||||
#### Configuration
|
||||
|
||||
MW_SERVER=http://example.org MW_SCRIPT_PATH=/dev/w npm run selenium
|
||||
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
|
||||
|
||||
- [Selenium/Node.js](https://www.mediawiki.org/wiki/Selenium/Node.js)
|
||||
- [Selenium/Node.js](https://www.mediawiki.org/wiki/Selenium/Node.js) on mediawiki.org
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# Check the command before running in background so
|
||||
# that it can actually fail and have a descriptive error
|
||||
hash chromedriver
|
||||
chromedriver --url-base=wd/hub --port=4444 &
|
||||
CHROME_DRIVER_PID=$!
|
||||
echo chromedriver running with PID $CHROME_DRIVER_PID
|
||||
# Make sure it is killed to prevent file descriptors leak
|
||||
function kill_chromedriver() {
|
||||
# Use kill instead of killall to increase chances of this working on Windows
|
||||
kill $CHROME_DRIVER_PID > /dev/null
|
||||
}
|
||||
trap kill_chromedriver EXIT
|
||||
npm run selenium-test
|
||||
Loading…
Reference in a new issue