This situation sounds like your team needs to come up with a plan for the
maximum allowed wait before that time renders.  Set a wait timer and if it
fails after the wait statement fail the test.  It's worked for me in the
past.  I would suggest 3-5 seconds maximum.

On Tue, Feb 21, 2012 at 10:37 AM, Chuck van der Linden <sqa...@gmail.com>wrote:

> is it possible the request is coming in while the frames are still
> being loaded?
>
> The Selenium docs (http://selenium.googlecode.com/svn/trunk/docs/api/
> rb/Selenium/WebDriver/Error/StaleElementReferenceError.html) for this
> error say: "Indicates that a reference to an element is now “stale” -
> the element no longer appears in the DOM of the page. "
>
> which makes me think your request is happening while some portion of
> the page is still loading, either content of a frame, some kind of
> jquery or ajax update that doesn't trigger the browser itself indicate
> a 'loading' state, etc.
>
> basically that means a race condition, most likely caused because your
> code is trying to proceed before the page is ready.
>
> Either use some kind of wait function to wait for that field to be
> present, (perhaps a cascade, wait for the first frame, then the inner
> frame, then the text field?)   or just a fixed sleep (easier to code
> but more likely to break or cause unwanted delay if your value is too
> small or too large)
>
> For example you could try using
>
>  browser.frame(:id => 'iFrame1').frame(:id => 'iFrame2).text_field(:id
> => 'text1').when_present.set('value')
>
> Or you might need to get more creative
>
>  browser.frame(:id => 'iFrame1').wait_until_present
>  browser.frame(:id => 'iFrame1').frame(:id =>
> 'iFrame2).wait_until_present
>  browser.frame(:id => 'iFrame1').frame(:id => 'iFrame2).text_field(:id
> => 'text1').when_present.set('value')
>
>  See http://watirwebdriver.com/waiting/ for more info on these
> methods.
>
>
>
> On Feb 21, 9:36 am, Sandra <sandra.wed...@googlemail.com> wrote:
> > thanks for your answer, but same error occurs with statement in one
> > line :(
> >
> > On 21 Feb., 18:31, Chuck van der Linden <sqa...@gmail.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > sounds like the contents of the page or of a frame are being updated
> > > and that is making one of your variables 'stale' in that it no longer
> > > references the current instance of the page and/or frame
> >
> > > instead of creating two objects and three lines of code, try doing it
> > > all at once on a single line
> >
> > > browser.frame(:id => 'iFrame1').frame(:id => 'iFrame2).text_field(:id
> > > => 'text1').set('value')
> >
> > > On Feb 21, 5:36 am, Sandra <sandra.wed...@googlemail.com> wrote:
> >
> > > > Hi!
> >
> > > > Yesterday I started testing a web application with watir and watir-
> > > > webdriver (using firefox) and get randomly (nearly every test run) an
> > > > error trying to access an element inside a nested iframe:
> >
> > > > Element belongs to a different frame than the current one - switch to
> > > > its containing frame to use it
> > > > (Selenium::WebDriver::Error::StaleElementReferenceError)
> > > >       [remote server] resource://fxdriver/modules/atoms.js:9574:in
> > > > `unknown'
> > > >       [remote server]
> > > > file:///tmp/webdriver-profile20120221-24798-10nxptg/extensions/
> fxdri...@googlecode.com/components/driver-component.js
> > > > -> file:///tmp/webdriver-profile20120221-24798-10nxptg/extensions/
> fxdri...@googlecode.com/components/firefoxDriver.js:575:in
> > > > `unknown'
> > > >       [remote server]
> > > > file:///tmp/webdriver-profile20120221-24798-10nxptg/extensions/
> fxdri...@googlecode.com/components/command_processor.js:10251:in
> > > > `unknown'
> > > >       [remote server]
> > > > file:///tmp/webdriver-profile20120221-24798-10nxptg/extensions/
> fxdri...@googlecode.com/components/command_processor.js:10256:in
> > > > `unknown'
> > > >       [remote server]
> > > > file:///tmp/webdriver-profile20120221-24798-10nxptg/extensions/
> fxdri...@googlecode.com/components/command_processor.js:10204:in
> > > > `unknown'
> >
> > > >  this is my code:
> >
> > > > my_frame_1 = BROWSER.frame(:id => 'iFrame1')
> > > > my_frame_2 = my_frame_1.frame(:id => 'iFrame2)
> > > > my_frame_2.text_field(:id => 'text1').set('value')
> >
> > > > I am using cucumber 1.1.4, webrat 0.7.3, watir-webdriver 0.5.3 and
> > > > Firefox 11.0 at a openSuSE 12.164bit system.
> >
> > > > Any glue or hint? Thanks in advance for your help,
> >
> > > >  Sandra Weddig
>
> --
> 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
>

-- 
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