IRB is your friend.

March 11, 2009 at 4:20 pm Leave a comment

They say that there’s no such thing as a dumb question, but we’ve all asked questions that we wish we could take back.  That’s why IRB and watir-console are so great when you’re writing Watir tests- you get to try out any command (or even a group of commands) to quickly see if it works without having to ask someone else or run your whole test.  The best part is that, unlike a post to a group, any totally off base attempts are not available for the world to see.

Think of IRB as a buffer for embarrassing questions.  Learn it, use it, love it.

From a command prompt:

C:>irb
irb(main):001:0> require 'watir'
=> true
irb(main):002:0> browser = Watir::Browser.new
=> a bunch of output describing the browser

irb(main):003:0> browser.goto('http://www.google.com')
=> 1.115
irb(main):004:0> browser.text_field(:name, 'q').set('watir information')
=> ""

If I try something that doesn’t work, I get a helpful error message:

irb(main):005:0> browser.text_field(:name, 'qwerty').set('watir information')
=>Watir::Exception::UnknownObjectException: Unable to locate element, using :name, "qwerty"
Advertisements

Entry filed under: Potentially Useful Stuff.

Ouch. How not to impress your boss.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories

Recent Tweets


%d bloggers like this: