2016-12-19 16:39:29 +00:00
|
|
|
# Selenium tests
|
|
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
|
|
- [Chrome](https://www.google.com/chrome/)
|
|
|
|
|
- [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/)
|
|
|
|
|
- [Node.js](https://nodejs.org/en/)
|
|
|
|
|
|
2018-04-21 01:10:56 +00:00
|
|
|
If using MediaWiki-Vagrant:
|
2016-12-19 16:39:29 +00:00
|
|
|
|
|
|
|
|
cd mediawiki/vagrant
|
|
|
|
|
vagrant up
|
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
|
|
cd mediawiki
|
|
|
|
|
npm install
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
npm run selenium
|
|
|
|
|
|
2018-03-30 16:42:04 +00:00
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
Example recording session:
|
|
|
|
|
|
|
|
|
|
sudo apt-get install chromedriver ffmpeg xvfb
|
|
|
|
|
export DISPLAY=:94
|
|
|
|
|
Xvfb "$DISPLAY" -screen 0 1280x1024x24 &
|
|
|
|
|
npm run selenium
|
|
|
|
|
|
|
|
|
|
Example visible session:
|
2017-06-09 13:40:31 +00:00
|
|
|
|
2018-04-21 01:10:56 +00:00
|
|
|
DISPLAY=1 npm run selenium
|
2017-06-09 13:40:31 +00:00
|
|
|
|
2018-05-02 17:48:24 +00:00
|
|
|
To run only one test (for example specs/page.js), you first need to start Chromedriver:
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2018-01-16 17:40:27 +00:00
|
|
|
chromedriver --url-base=wd/hub --port=4444
|
2018-01-13 11:52:26 +00:00
|
|
|
|
2018-05-02 17:48:24 +00:00
|
|
|
Then, in another terminal:
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2018-05-02 17:48:24 +00:00
|
|
|
npm run selenium-test -- --spec tests/selenium/specs/page.js
|
2016-12-19 16:39:29 +00:00
|
|
|
|
2018-05-02 17:48:24 +00:00
|
|
|
You can also filter specific cases, for ones that contain the string 'preferences':
|
2017-11-28 13:26:42 +00:00
|
|
|
|
2018-05-02 17:48:24 +00:00
|
|
|
npm run selenium-test -- tests/selenium/specs/user.js --mochaOpts.grep preferences
|
2017-11-28 13:26:42 +00:00
|
|
|
|
2018-05-02 17:48:24 +00:00
|
|
|
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
|
2016-12-19 16:39:29 +00:00
|
|
|
variables:
|
|
|
|
|
|
2018-05-02 17:48:24 +00:00
|
|
|
- `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
|
2016-12-19 16:39:29 +00:00
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
|
|
MW_SERVER=http://example.org MW_SCRIPT_PATH=/dev/w npm run selenium
|
|
|
|
|
|
2018-05-02 17:48:24 +00:00
|
|
|
## Further reading
|
2016-12-19 16:39:29 +00:00
|
|
|
|
|
|
|
|
- [Selenium/Node.js](https://www.mediawiki.org/wiki/Selenium/Node.js)
|