Merge "Selenium: replace UserLoginPage with BlankPage where possible"
[lhc/web/wiklou.git] / tests / selenium / README.md
1 # Selenium tests
2
3 ## Prerequisites
4
5 - [Chrome](https://www.google.com/chrome/)
6 - [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/)
7 - [Node.js](https://nodejs.org/en/)
8
9 If using MediaWiki-Vagrant:
10
11 cd mediawiki/vagrant
12 vagrant up
13
14 ## Installation
15
16 cd mediawiki
17 npm install
18
19 ## Usage
20
21 npm run selenium
22
23 There are three supported modes of running the tests:
24
25 - Headless. It's the default. You will not see the browser while tests are
26 running because it's running in a headless mode. This mode should run fine
27 on all supported platforms.
28 - Headless recording. Set DISPLAY environment variable to a value that starts
29 with colon (`:`) and video of each test will be recorded. Browser will run
30 headless. Recording videos works only on Linux.
31 - Visible. If you want to see the browser, set DISPLAY environment variable to
32 any value that does not start with colon. This mode will not work in a
33 headless environment like MediaWiki-Vagrant.
34
35 Example recording session:
36
37 sudo apt-get install chromedriver ffmpeg xvfb
38 export DISPLAY=:94
39 Xvfb "$DISPLAY" -screen 0 1280x1024x24 &
40 npm run selenium
41
42 Example visible session:
43
44 DISPLAY=1 npm run selenium
45
46 To run only one test (for example specs/page.js), you first need to start Chromedriver:
47
48 chromedriver --url-base=wd/hub --port=4444
49
50 Then, in another terminal:
51
52 npm run selenium-test -- --spec tests/selenium/specs/page.js
53
54 You can also filter specific cases, for ones that contain the string 'preferences':
55
56 npm run selenium-test -- tests/selenium/specs/user.js --mochaOpts.grep preferences
57
58 The runner reads the configuration from `wdio.conf.js`. The defaults target
59 a MediaWiki-Vagrant installation on `http://127.0.0.1:8080` with a user "Admin"
60 and password "vagrant". Those settings can be overridden using environment
61 variables:
62
63 - `MW_SERVER`: to be set to the value of your $wgServer
64 - `MW_SCRIPT_PATH`: ditto with $wgScriptPath
65 - `MEDIAWIKI_USER`: username of an account that can create users on the wiki
66 - `MEDIAWIKI_PASSWORD`: password for above user
67
68 Example:
69
70 MW_SERVER=http://example.org MW_SCRIPT_PATH=/dev/w npm run selenium
71
72 ## Further reading
73
74 - [Selenium/Node.js](https://www.mediawiki.org/wiki/Selenium/Node.js)