Selenium/Node.js/Inside MediaWiki-Vagrant

From MediaWiki.org
Jump to navigation Jump to search
Warning Warning: Instructions on this page are not working at the moment. See T236282.

For this example, we will not enable any roles and we will use MediaWiki core.

From MediaWiki-Vagrant machine.png

Advantages[edit]

Running Selenium tests from inside MediaWiki-Vagrant machine has several advantages:

  • You do not have to install anything on your machine, except MediaWiki-Vagrant itself, and it's dependencies.
  • It will be fast, since the target machine is local. MediaWiki core Selenium test run takes about 3 minutes on my machine. (As of September 2019.)
  • After everything is set up, you do not need internet connection.
  • You are probably already familiar with MediaWiki-Vagrant and have it installed.
  • While the tests are running, you can continue using your machine as usual, because everything is happening inside the virtual machine.

Disadvantages[edit]

  • You might not be familiar with MediaWiki-Vagrant, so you will have to learn how to install and use yet another tool.
  • You will have to install MediaWiki-Vagrant and it's dependencies on your machine.
  • The machine is headless (no display) so it is harder to debug failed tests, but not impossible.

Set up MediaWiki-Vagrant[edit]

Boot the machine[edit]

$ vagrant up

SSH into the machine[edit]

$ vagrant ssh

Go to mediawiki folder[edit]

vagrant@vagrant:~$ cd /vagrant/mediawiki

Install dependencies in the machine[edit]

vagrant@vagrant:/vagrant/mediawiki$ sudo apt-get install chromedriver

[citation needed]

vagrant@vagrant:/vagrant/mediawiki$ npm install

Run the Selenium tests[edit]

vagrant@vagrant:/vagrant/mediawiki$ npm run selenium

Run the Selenium tests and record video of each test[edit]

vagrant@vagrant:/vagrant/mediawiki$ sudo apt-get install chromedriver ffmpeg xvfb
...

vagrant@vagrant:/vagrant/mediawiki$ export DISPLAY=:94

vagrant@vagrant:/vagrant/mediawiki$ Xvfb "$DISPLAY" -screen 0 1280x1024x24 &
[1] 2053

vagrant@vagrant:/vagrant/mediawiki$ npm run selenium

Videos are in log folder. You can play them using a video player like VLC.

vagrant@vagrant:/vagrant/mediawiki$ ls tests/selenium/log/
BlankPage-should-have-its-title.mp4  Page-should-be-re-creatable.png            User-should-be-able-to-log-in.mp4  WDIO.xunitchrome.0-3.xml
Page-should-be-creatable.mp4         Page-should-be-restorable.png              User-should-be-able-to-log-in.png  WDIO.xunitchrome.0-4.xml
Page-should-be-deletable.mp4         Page-should-have-history.mp4               WDIO.xunitchrome.0-0.xml
Page-should-be-editable.mp4          Page-should-have-history.png               WDIO.xunitchrome.0-1.xml
Page-should-be-re-creatable.mp4      User-should-be-able-to-create-account.mp4  WDIO.xunitchrome.0-2.xml

Exit the machine[edit]

  • ctrl+d or logout
vagrant@vagrant:~$ logout

suspend or halt the machine[edit]

$ vagrant suspend

or

$ vagrant halt