[Wtr-general] Syntax for relative attributes
Christian Kreutzer
herr.kreutzer at googlemail.com
Mon Jan 8 04:10:59 EST 2007
On 12/22/06, Bret Pettichord <bret at pettichord.com> wrote:
> So we have consistently urged people to wrap their watir expressions in
> methods rather than assign them to global variables. This makes it easy
> to reuse them, and ensure that a correct rebinding occurs on each reuse.
> Also, as i have been using Watir more on large projects, i am finding
> that there are other reasons why this is a sound way to structure Watir
> libraries.
im not sure if i understand this correctly.
text = $ie.text <-- so, this is bad because we cant be sure if the
rebinding happens just in time when we need it.
would the following approach be better?:
class Page
def initialize ie
@ie = ie
end
def text
@ie.text
end
end
p = Page.new ie
puts p.text
the watir expressions are now wrapped in methods but i cant see how
the object binding could be different from using global vars. I hope
someone can enlighten me on this ;)
Christian
More information about the Wtr-general
mailing list