Not that I really work with testing anymore, it still interest me. Well at least getting it more and more automated.
So getting Selenium 2.0 running on my windows laptop sounded like a good summer activity.
In fairness the people responsible for both Selenium 2.0 and selenium-webdriver (which is the ruby frontend, packaged as a ruby gem) did a fantastic job.
You need following installed to get it working:
Firefox (or else you can change the example code to use IE or Chrome etc.)
Ruby 1.9
(Selenium 2.0)
And a few more stuff detailed below.
- I installed first ruby 1.8.7 and the ruby 1.9.1 from the one-click installers.
- Then I went to the SeleniumHQ and specifically they're Webdriver page.
- Downloaded the complete package (selenium-server-2.0a5.zip) from the downloads page.
- Unpacked it and added that directory to the CLASSPATH environment variable (I used C:\selenium-2.0a5).
- Fired up a cmd prompt and installed the selenium-webdriver gem (gem install selenium-webdriver).
- Navigated to the ruby bindings webpage for the WebDriver API => http://code.google.com/p/selenium/wiki/RubyBindings
- Fired up gvim (feel free to use your favorite editor here!)
- Copy and pasted they're first example and it failed horrible. (Note that on some systems you will need 'require "rubygems"', best is to always use it). Save as google_test.rb
- Googled the problem "msvcrt-ruby18.dll selenium-webdriver", found a related watir problem => http://code.google.com/p/selenium/issues/detail?id=583
- Installed the devkit from rubyinstaller.org, devkit is available for download on this page => http://rubyinstaller.org/downloads/
- unpacked the contents into my ruby 1.9 directory (I use C:\Ruby191)
- fired up the cmd again and ran
gem uninstall win32-api
gem install win32-api --platform=ruby
as detailed in the watir fix - Then "ruby google_test.rb" in the cmd and everything worked as intended!