Selenium/How-to/Run tests targeting MediaWiki-Vagrant using Sauce Labs

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

Target MediaWiki-Vagrant virtual machine using Sauce Labs.png


  • While the tests are running, you can continue using your machine as usual, because browser is running inside a virtual machine at Sauce Labs.
  • Debugging failed tests will be easier, since you will see the browser, logs, screenshots and video of the test run.
  • You do not have to have Chrome installed.
  • You can run tests using any operating system and browser combination that Sauce Labs supports.
  • You are probably already familiar with MediaWiki-Vagrant and have it installed.


  • The tests will be slower since the browser is running on a remote machine. MediaWiki core Selenium test run takes about 5 minutes on my machine. (As of September 2019.)
  • You will need internet connection while running the tests.
  • 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-VagrantEdit

Boot the machineEdit

$ vagrant up

Go to mediawiki folderEdit

$ cd mediawiki

Install dependenciesEdit

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


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

Sauce Connect ProxyEdit

Sauce LabsEdit

Create Sauce Labs account if you do not have one.

Environment variablesEdit

Ensure the following environment variables are set. Either run this manually from the terminal or, to make it easier for next time, set them from shell configuration file (~/.bash_profile, ~/.zshrc...) which means the variables are always available from any terminal session:

export DISPLAY=1
export SAUCE_USERNAME=sauce_username
export SAUCE_ACCESS_KEY=sauce_access_key

sauce_username is your Sauce Labs username. sauce_access_key is Access Key from Sauce Labs My Account page ( as of September 2019).

Run the Selenium testsEdit

Run these commands in two terminal windows or tabs.

$ npm run selenium-test

suspend or halt the machineEdit

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


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