Željko Filipin's Blog on Software and Testing

Test like you do not need the money.

Archive for March, 2006

How to Organize Watir Files

without comments

My Watir scripts became too big for one file, so I split them in several files. But then number of files became too big so I moved them to folders. Something like this

- conf (folder: yaml configuration files)
— builder.yml
— stager.yml

- file (folder: files for upload)
— file.txt
— attachment.txt

- lib (folder: files that contain my modules, classes, methods…)
— File.rb
— User.rb

- test (folder: files that contain tests)
— all_tests.rb
— core_tests.rb
— file_tests.rb
— user_tests.rb

And it works just fine. Just add this code at the top of files that need it (all_tests.rb, core_tests.rb…):

$:.unshift File.join(File.dirname(__FILE__), “..”, “lib”)
require “file_name”

Written by Željko Filipin

March 24th, 2006 at 1:57 pm

Posted in Watir

Ruby Variables and Objects

without comments

Brian Marick wrote interesting article about variables and objects.

The key to avoiding misunderstanding is remembering that variables and objects are *different kinds of things*. The name of a thing is not the thing itself. This is best illustrated by pictures. I just drew some pictures that explain what was happening in your example. (I simplified to make it just one each, since the nested eaches don’t have anything to do with the problem you had.) They are here: http://www.testing.com/review-copies/variables.pdf I’m rather pleased with them, plus I stayed up way too late to make them, so you all have to look at them.

Written by Željko Filipin

March 24th, 2006 at 1:53 pm

Posted in Ruby

FireWatir (WATiR on Firefox) Alpha v1.0 Works!

without comments

I found the reason why FireWatir was not working at my machine.

Installation guide for FireWatir in step 2.e. says:

Close Firefox. Restart it again using command “[Firefox installation directory]/firefox.exe –jssh” from command prompt.

I opened Command Prompt at Firefox installation directory and copy/pasted “firefox.exe –jssh” (of course, without quotes) there. Pressed enter.

The next step (2.f.) is:

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

I copy/pasted “telnet localhost 9997″ (also without quotes) to command prompt, pressed enter and got error message.

It took some time and a pretty long conversation at wtr-general mailing list to find the solution to my problem. At the end, I found it myself.

It seems that Word Replaces hypen (shorter -) with dash (longer –).

You can find that setting here:

Word (2003, service pack 2) > Tools > AutoCorrect Options… > AutoFormat > Replace > Hypens (–) with dash (–).

When I replaced dash (longer –) with hypen (shorter -) in “firefox.exe –jssh”, everything worked just fine.

What have I learned? Never write documentation in Word. Do it in Notepad.

The whole conversation is here.

Written by Željko Filipin

March 20th, 2006 at 1:49 pm

Posted in Watir