The WebDriverEx project contains examples of selenium tests.
The tests are developed in ruby.
The native Webdriver is used to drive the automation on the webpages.
The structure of the tests is using rspec.
In web development crucial areas of the code base are candidates for automation. We cannot automate the testing effort of the entire system with selenium scripts alone. These tests need to be used with unit, integration, and smoke tests as part of an effective testing strategy.
setup clean environment:
for windows users(otherwise skip):
-download and install VirtualBox
-download Ubuntu .iso file
-with virtualBox create a new machine
-start the machine and install Ubuntu with the iso file
Now in linux environment:
-ensure the operating system is up to date
-sudo apt-get update
-sudo apt-get install virtualbox-ose-guest-utils (allow full screen for virtualbox)
*At this point power down your vm and restart the vm (you will have options to switch to full screen rather than envelope full screen)
-with VirtualBox take a snapshot of the vm and name it "clean" (if required)
-sudo apt-get install ruby1.9.1 (language tests are written in)
-sudo apt-get install rubygems (for installing ruby specific libs)
-sudo gem install rspec (for defining tests in a BDD style format)
-sudo gem install rake (for running tasks in order, such as our tests "rake functional")
-sudo gem install selenium-webdriver (control a browser using a programming language)
-sudo apt-get install apache (for running the webserver)
-sudo apt-get install mercurial (checking out code from this site)
-sudo apt-get install sqlite3 (needed for running tests)
-sudo apt-get install libsqlite3-dev (neede for running tests)
-sudo gem install sqlite3-ruby (sqlite3 for ruby)
finally checkout the code into the /var/www/ directory
the .rb files contain the code for opening a web browser and asserting against the structure of the webpage.
to run rests:
rspec {testname}.rb
Distributed testing:
-sudo apt-get install openjdk-7-jre (java run time environment)
-wget http://selenium.googlecode.com/files/selenium-server-standalone-2.21.0.jar (download the selenium server)
-open a terminal:
java -jar selenium-server-standalone-{version}.jar -role hub (start the hub)
-open another terminal:
java -jar selenium-server-standalone-{version}.jar -role node -hub http://localhost:4444
/grid/register (start a node)
I would recommend having one node per gb of system memory
Viewing the hub http://localhost:4444/grid/console
Taking it to the next level is starting vms in a cloud environment. Then they register with a hub. Or just starting a vm to run a suite then publish the results and close down (without using a hub)
custom command line args is
help= rspec {testname}.rb
You can have the hub on different vms, and nodes as well. Specify the uri of the hub. nodes cannot share the same port number so when starting nodes -port {port_number} is handy.
The wiki uses Markdown syntax.