in the first case your variable is being set to reference an specific
object within the browser object, once you change the page the
contents of the browser object change and the one you were
referencing  no longer exists.   In the second case you are setting it
to a specific value, not a reference to an object, so changing the
page has no effect on the value.

On May 24, 7:05 am, Abe Heward <[email protected]> wrote:
> So, I navigate to a page on my test site and define a bunch of variables as
> page objects, like so:
>
> site_name = browser.text_field(:id, "sitename")
> site_url = browser.text_field(:id, "url")
> etc. ...
>
> I then navigate to a new page with a browser.goto. On the new page I define
> some additional variables, like so:
>
> campaign_name = browser.text_field(:id, "campname")
> etc. ...
>
> However, if I now want to get a site_name.value it turns out that it's
> empty.
>
> In some sense I can understand why this is the case, but in others I can't.
>
> Can someone explain the thinking behind the decision that led to Watir being
> built this way?
>
> I can easily switch my variable definitions to look like this:
>
> site_name = browser.text_field(:id, "sitename").value
>
> ... but that seems to rob me of a lot of the flexibility (and code
> readability) that Watir has to offer.

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

[email protected]
http://groups.google.com/group/watir-general
[email protected]

Reply via email to