Selenium/Node.js/Target MediaWiki-Vagrant

From MediaWiki.org
Jump to navigation Jump to search

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


Advantages[edit]

Running Selenium tests targeting MediaWiki-Vagrant machine has several advantages:

  • It will be fast, since the target machine is local. MediaWiki core Selenium test run takes about 2 minutes on my machine. (As of September 2019.)
  • After everything is set up, you do not need internet connection.
  • Debugging failed tests will be easier, since are able to see the browser using DISPLAY environment variable. See README.md for more information.
  • You are probably already familiar with MediaWiki-Vagrant and have it installed.

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, Selenium and their dependencies on your machine.

Set up MediaWiki-Vagrant[edit]

Boot the machine[edit]

$ vagrant up

Go to mediawiki folder[edit]

$ cd mediawiki

Install dependencies[edit]

Depending on your operating system, installing dependencies will be different.

Chrome[edit]

Node.js[edit]

  • Install Node.js.
  • Install required npm packages.
$ npm ci

Run Selenium tests[edit]

Run Chromedriver in one terminal window or tab:

$ chromedriver --url-base=wd/hub --port=4444

Run Selenium tests in another terminal window or tab:

$ npm run selenium-test

suspend or halt the machine[edit]

$ vagrant suspend
==> default: Saving VM state and suspending execution...

or

$ vagrant halt
==> default: Attempting graceful shutdown of VM...