Friday, October 2, 2009

Watir Tutorials: Watir and FireWatir Installation and Setup

Previous blog - Watir QA Automation: Watir Setup - Part I: Installing Ruby explain how to install Ruby on various platforms. This article explains how to install various types of Watir for different browsers and validate your installation.


Watir support Microsoft Internet Explorer [IE], FireFox and Safari browsers. There are separate Watir frameworks for each of these browsers.

  • Watir for IE

  • FireWatir for FireFox

  • SafariWatir for Safari


Since these are separate projects, the version of each of these Watir variations may not be same. I noticed that some of the features are supported by Watir are not available in FireWatir or vice-versa. This sometimes make writing cross browser test cases more challenging. Later I'll discuss this in details about writing interoperable, reusable and cross browser test cases without maintaining test suites for each browsers. We will postpone this discussion till then.


Prerequisites


In order to install Watir, you will need gem. Gem should get automatically installed when you install Ruby. Please refer to previous blog for Ruby installation -


You can verify whether gem is installed by typing the command gem or gem -v on the command prompt



C:\apptests\trunk\test_suite>gem
RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.
Usage:
gem -h/--help
gem -v/--version
gem command [arguments...] [options...]
Examples:
gem install rake
gem list --local
gem build package.gemspec
gem help install
Further help:
gem help commands list all 'gem' commands
gem help examples show some examples of usage
gem help show help on COMMAND
(e.g. 'gem help install')
Further information:
http://rubygems.rubyforge.org
C:\apptests\trunk\test_suite>gem -v
0.9.4

If you want to grab the newer version of gem or you do not have gem installed, then go to http://rubygems.rubyforge.org/ or http://docs.rubygems.org/ and install gem. You will find the gem binaries, install instructions and documentation for gem here.


You can also verify whether you had any Watir frameworks installed using gem list



C:\apptests\trunk\test_suite>gem list |grep watir
commonwatir (1.6.2)
Common code used by Watir and FireWatir
firewatir (1.6.2)
flash_watir (1.1.0)
an extension for watir to test flash applications in firefox.
watir (1.6.2)

If you have any older versions of Watir installed then I would recommend to uninstall those before installing the newer versions.


It is possible that you might have latest-greatest version of watir already installed, so before you start uninstalling the existing version, check the gem list. Latest versions of the available gems are published periodically at http://gems.rubyforge.vm.bytemark.co.uk/gems/ and http://gems.rubyforge.org/gems/


Watir for Internet Explorer


Installing watir is as easy as execution one command. If you want specific version of watir then specify version number with -v option



gem install watir
gem install watir -v 1.6.2


Verify your Watir installation



gem list --local


this will list all gem installed on your computer

OR

if use gem list watir, will list only watir info.



C:\apptests\trunk\test_suite>gem list watir
*** LOCAL GEMS ***
watir (1.6.2)
Automated testing tool for web applications.

FireWatir for FireFox


FireWatir setup requires one extra step than installing Watir for IE


  • Install FireWatir and

  • Install JSSH plugins for FireFox


In following section we will explore each of this in details.

Installing FireWatir for FireFox


Installing firewatir is same process as installing watir, only gem name is different. If you want specific version of firewatir then specify version number with -v option



gem install firewatir
gem install firewatir -v 1.6.2

Verify your FireWatir installation



gem list --local

this will list all gem installed on your computer

OR

if use gem list watir, will list only firewatir info.



C:\apptests\trunk\test_suite>gem list firewatir
*** LOCAL GEMS ***
firewatir (1.6.2)
Automated testing tool for web applications using FireFox browser.

Install JSSH for FireFox


To run the FireWatir test cases in FireFox you need to install JSSH [javascript shell] plugins for FireFox


If you do not have FireFox installed yet, then download Firefox browser from http://www.mozilla.com and install it.


Follow the following steps to install JSSH plugins

  • Download .XPI file from http://code.google.com/p/firewatir/downloads/list

  • Start Firefox browser.

  • From File menu select Open File option.

  • Navigate to the path where the downloaded .XPI file is located. Select the .XPI file click open.

  • Wait till a dialog appear stating that do you want to install this extension.

  • Click install.

  • The extension will now show up in the installed extensions list.


For checking the installation of JSSH extension; follow steps below
  • Close Firefox.

  • Restart it from command prompt using "Firefox installation directory/firefox.exe -jssh". Make sure you give "-jssh" as parameter otherwise Firefox will not start JSSh shell.

  • To check if JSSh is listening on port 9997 run command "telnet localhost 9997" from command prompt.

No comments:

Post a Comment