diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2019-09-20 18:37:36 +0100 |
---|---|---|
committer | Krinkle <krinklemail@gmail.com> | 2019-10-03 17:17:28 +0000 |
commit | ebda397c54502a52ba0c4e6ee29fb8010b952ff8 (patch) | |
tree | fe7512034da6b56db483f99dc6d1391559c3066c /tests/selenium/README.md | |
parent | da4d9b575f8c88f486105ba0d84c188ad0518168 (diff) | |
download | mediawikicore-ebda397c54502a52ba0c4e6ee29fb8010b952ff8.tar.gz mediawikicore-ebda397c54502a52ba0c4e6ee29fb8010b952ff8.zip |
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 1955a8aa564,
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
Diffstat (limited to 'tests/selenium/README.md')
-rw-r--r-- | tests/selenium/README.md | 82 |
1 files changed, 38 insertions, 44 deletions
diff --git a/tests/selenium/README.md b/tests/selenium/README.md index 038b75729e6d..4db770d6482d 100644 --- a/tests/selenium/README.md +++ b/tests/selenium/README.md @@ -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 +## Usage -## Installation +There are three supported modes of running the tests. - cd mediawiki - npm install +#### Headless -## Usage +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: - -- 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. +Or: -Example recording session: + DISPLAY= npm run selenium - sudo apt-get install chromedriver ffmpeg xvfb - export DISPLAY=:94 - Xvfb "$DISPLAY" -screen 0 1280x1024x24 & - npm run selenium +#### Visible browser -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 + +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: - chromedriver --url-base=wd/hub --port=4444 + DISPLAY=:2 npm run selenium -Then, in another terminal: +#### Filter - npm run selenium-test -- --spec tests/selenium/specs/page.js +Run a specific spec: -You can also filter specific cases, for ones that contain the string 'preferences': + npm run selenium -- --spec tests/selenium/specs/page.js - npm run selenium-test -- tests/selenium/specs/user.js --mochaOpts.grep preferences +To filter by test case, e.g. with the name containing "preferences": -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: + npm run selenium -- --mochaOpts.grep 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 +#### Configuration -Example: +The following environment variables decide where to find MediaWiki and how to login: - MW_SERVER=http://example.org MW_SCRIPT_PATH=/dev/w npm run selenium +- `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 |