Friday, January 28, 2011

Ubuntu 8.10 With Firewatir

Some kind Ruby Enthusiasts built a tool called Watir (Web Application Testing in Ruby) which basically allows you to programmatically control a web browser (Specifically Microsoft Internet Explorer). From a Software Quality Assurance standpoint this allows the developers to automate much of what is typically a manual process.
However, IE is not the only browser in the world (and if I had my way it would be eliminated from the face of the earth), and thus has has grown related projects Such as FireWatir which runs Firefox instead of IE.
Last summer's google summer of code involved some refactoring of the Watir code to work more uniformely with FireWatir (and I believe the safari equivalent as well -- although I haven't used that so I can't confirm). Anyways, the process of using watir/firewatir is pretty simple. First, setup your requires/includes

view sourceprint?
1 #may not need rubygems if your system is setup right

2 require 'rubygems'

3 require 'watir'

4 require 'firewatir'

5

6 include FireWatir
Then you do

view sourceprint?
1 browser = Watir::Browser.new

2 #instead of browser = Watir::IE.new
For more information on Watir::Browser check this page:
http://wiki.openqa.org/display/WTR/Browser.new

Unfortunately it doesn't appear the RDocs have been updated to include Watir::Browser

This all works great on windows (who would have guessed), but I've been having trouble setting up Firefox to work with Firewatir in Ubuntu 8.10 linux. I've used several different JSSH extensions that are supposedly compatible with FF on linux (and they appear to install just fine). Those extensions can be found here:
http://wiki.openqa.org/display/WTR/FireWatir+Installation
and here:
http://www.valibuk.net/2008/11/jssh-firefox-30-with-optional-port-number/

Neither seem to work though. I've tried just about everything I can think of, but I can never get telnet to connect to port 9997 after I've loaded the extension into firefox (and restarted, and setup firefox preferences according to tutorials found
here
and
here
and several others. But nothing, I always get the following error when attempting to do either Firefox.new or Watir::Browser.new :

Watir::Exception::UnableToStartJSShException:
Unable to connect to machine : 127.0.0.1 on port 9997.
Make sure that JSSh is properly installed and Firefox
is running with '-jssh' option
I have yet to come up with a working solution, however I'm in the process of building firefox from source and enabling jssh in the build (which should solve the problem).

The build process I've essentially stolen from the firefox build process documentation and utilized from:
http://ubuntu-snippets.blogspot.com/2008/07/build-firefox-3-web-browser-...
and
https://developer.mozilla.org/En/Simple_build

Basically, I pull the source code with hg (mercurial), and use the newer build process documented on the mozilla site, while creating a .mozconfig file as noted in the other tutorial. The one change I had to make to the .mozconfig was I removed the webservices extension since it doesn't seem to be avaiable anymore (I was getting an error when I left it).

Anyways, if anyone has got JSSH working with ubuntu 8.10 I'd love to know how you did it.
Check back often as I shall report with news of whether or not this is working fairly soon.

--- Follow Up --3/22/2009
After finding out that selenium can now be used without using server side javascript code directly I switched to that. I'm now using that with cucumber and have come up with some cool ways of automating tests in multiple browsers. Check back soon, I should have a blog with some details on my setup.

--- Follow Up --4/30/2009

No comments:

Post a Comment