Selenium/Ruby/Inside MediaWiki-Vagrant virtual machine

From mediawiki.org
< Selenium‎ | Ruby
Jump to navigation Jump to search

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 also be fast, since the target machine is local.
    • MediaWiki core Selenium test run takes about 3-4 minutes on my machine.
    • It takes about 6-7 minutes for selenium-Core Jenkins job to run.
  • 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 an extension folder[edit]

$ cd /vagrant/mediawiki/extensions/EXTENSION

Install dependencies in the machine[edit]

You will need internet access for this step. Ruby 2.0 or newer is required. Third-party tools like rbenv or RVM are not required.

$ sudo apt-get install chromedriver xvfb
$ sudo gem install bundler --no-rdoc --no-ri
$ bundle install

Run the Selenium tests[edit]

$ export PATH=$PATH:/usr/lib/chromium/
$ MEDIAWIKI_ENVIRONMENT=mw-vagrant-guest bundle exec rake selenium

Exit the machine[edit]

  • ctrl+d or logout
vagrant@mediawiki-vagrant:~$ logout
Connection to 127.0.0.1 closed.

suspend or halt the machine[edit]

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

or

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