I hesitate to ask this question because I feel like the answer will end up 
being blindingly obvious or else horribly complicated. Plus, I suppose it's 
more of a Ruby question than a Watir one.  I'll ask it anyway...

I have a page that has a list of documents on it. You can do typical things 
to these documents--open, copy, delete... etc.

Currently, I have a page class I've created with custom methods that look 
something like this:

def open(name)
  @browser.li(:text=>name).button(:title=>"open").click
end

So when I instantiate the page's class my test scripts look, for example, 
like this:

library.open "file.txt"

What I'm wondering, though, is if it's a simple matter to create a 
class/method structure that would allow code that would, instead, look like 
this:

library.document("file.txt").open

I thought I had a way to do this, but--in retrospect not surprisingly--I 
get an undefined method error because the class of the document("file.txt") 
object is Watir::LI. Duh.

Still, it seems like if there's a simple way to do this it would DRY up my 
code quite a bit.

Thanks for reading!

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

Reply via email to