Have you looked at something along the lines of defining a page object which would allow you to create an handy label for the object (e.g. the cell in the table) and you should then be able to just address it like
pagename.site_id.text Alister has a series of blog postings on this pattern in his Watirmelon blog http://watirmelon.com/tag/page-object-pattern/ On Oct 12, 8:46 am, Abe Heward <[email protected]> wrote: > I'm seeing an annoying issue that I suspect has to do with objects inside > page frames and Selenium and Watir-Webdriver. > > I brought up part of it already in this > post:https://groups.google.com/d/topic/watir-general/gIgtHbFxfbw/discussion > > Here's a similar issue: > > If I reference some text on a page like this: > > @browser.frame(:index=>0).table(:class=>"itemSummary").td(:class=>"shorttext", > :index=>0).text > > ...it will work fine. I get the text I need, just as expected. > > However, that's a nasty long bit of code and I don't want to have to use > that string every time I need that page object. So I defined a method. > > def site_id > > @browser.frame(:index=>0).table(:class=>"itemSummary").td(:class=>"shorttext", > :index=>0).text > end > > Sadly, when I call the method in my scripts, I get... > > *Selenium::WebDriver::Error::ObsoleteElementError: Element not found in the > cache* > * > * > There's no way it's an obsolete element, because the class containing that > method gets instantiated *immediately* before the method is called. > > Is this a known issue? Any ideas for a way around this that will allow me > to continue to use my method instead of the explicit call to the object? -- 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]
