At my workplace, we had a dedicated Selenium Server which sits in the AWS cloud.
We would use it to be able to run our test suites against a real web browser.
By having a selenium server in the cloud we could then use Madcow or any other selenium/webdriver supported language for our web application testing requirements.
But when AWS did updates ubuntu packages or anything changed, the system was started/stopped everything would come crumbling down again.
I had heard, read and played a little with Vagrant which is basically a Developer Environment Virtual Machine management system but not used it yet.
Then I stumbled upon this awesome article about Running Headles Selenium With Chrome by Chris Le
which basically achieves what I was thinking about doing, but just needed a little tweaking.
First I went off and installed latest version of vagrant and virtualbox.
Then I installed the vagrant precise64 bit box by running…
Then I installed the vagrant aws provider plugin by running…
1
vagrant plugin install vagrant-aws
Next I created my Vagrantfile… again, slightly tweaked from Chris’ to suit our requirements (e.g. ebs backed instance)
Basically we had a few more requirements, we wanted the remote server to be able to run firefox, phantomjs and chrome so to be able to do that I had to add a few more items to the setup.sh script.
It’s included below:
Then once I was done I could simply fire up a local ubuntu VM with all the stuff I need to run selenium tests against by exacuting
1
vagrant up
at the command line.
If I wanted my solution in the AWS cloud however, it was a simple matter of running
1
vagrant up --provider=aws
Once it does it’s thing I can ssh on to the VM by running
1
vagrant ssh
which I needed to do to get the AWS public DNS IP.
It will even rsync the current folder to the VM’s /vagrant directory, so I can run all my tests right here on the VM if I wanted to.
To run my webdriver (or remote Madcow in my case) tests from my host I can also simply point them to the remote server url endpoint of
1
http://localhost:4444/wd/hub
and then wait for my test results.
Bam webdriver selenium test server setup and ready to go in minutes.
Note: I also tried to configure an elastic IP setup for AWS provider run but was unsuccesful. I will update here when/if I get that working.