here was one of the ideas I tried.
In essence, what it does is create a method called the_search_box that
returns the ie.text_field object.
Im sure there are some better ways of doing it.
Paul
require 'watir'
class WatirNaming
def self.parse_ops( obj_name , opts )
if opts.has_key? :id
how = :id
elsif opts.has_key? :name
how = :name
elsif opts.has_key? :index
how = :index
else
raise "No Idea how to find that object"
end
what = opts[ how ]
mname = eval(":#{obj_name}")
return how , what , mname
end
def self.text_field( obj_name , opts )
how, what , mname = self.parse_ops( obj_name , opts )
define_method( mname ) { @ie.text_field( how , what ) }
end
end
class D < WatirNaming
text_field "the_search_box" , :name => 'q'
def initialize
@ie = Watir::IE.attach(:title , /google/i )
the_search_box.set('abc')
end
end
d=D.new
----- Original Message -----
From: "aidy lewis" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, March 28, 2007 10:55 AM
Subject: Re: [Wtr-general] little framework
> Hi Paul,
>
> Could you just please explain how you are mapping something like this:
>
> text_field :user_name , :id=>'username'
>
> in the parent class?
>
> cheers
>
> aidy
> _______________________________________________
> Wtr-general mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-general
>
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general