Selenium/Ruby/Target MediaWiki-Vagrant virtual machine

< Selenium‎ | Ruby

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 3 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.
  • Debugging failed tests will be easier, since you will see the browser.
  • 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.
  • While the tests are running the host machine will be hard to use because Chrome will be opening and closing for every test (but not stealing focus).

Set up MediaWiki-Vagrant edit

Boot the machine edit

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
...
==> default: Notice: Finished catalog run in 248.92 seconds

Go to mediawiki folder edit

$ cd mediawiki

Install dependencies edit

You will need internet access for this step. Depending on your operating system, installing dependencies will be different.

Chrome edit

Ruby edit

Installing Ruby might be easier, or harder.

  • On Linux, please use appropriate package manager.
  • On Windows, please use RubyInstaller.
  • It should already installed on Mac machines.
  • Ruby 2.0 or newer is required.
  • Third-party tools like rbenv or RVM are not required.

After installation, check if everything is all right.

$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

Install required Ruby packages (gems).

$ gem install bundler --no-rdoc --no-ri
Fetching: bundler-1.13.6.gem (100%)
Successfully installed bundler-1.13.6
1 gem installed
$ bundle install
...
Use `bundle show [gemname]` to see where a bundled gem is installed.

Run the Selenium tests edit

$ bundle exec rake selenium
...
/usr/local/Cellar/ruby/2.4.0/bin/ruby -S bundle exec cucumber tests/browser --tags @chrome
...
20 scenarios (20 passed)
103 steps (103 passed)
1m8.896s

suspend or halt the machine edit

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

or

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