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:

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

irb(main):003:0> browser.goto('')
=> 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"

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: Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Recent Tweets

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: