ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Bad error switching frames #963

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Error thrown when switching to a frame element the driver is already on should 
be consistent.

driver.switch_to.frame('frame_id')

# Passes as expected:
expect {browser.driver.switch_to.frame('frame_id')}.to 
raise_error(Selenium::WebDriver::Error::NoSuchFrameError)

browser.driver.switch_to.default_content
frame_element = browser.driver[id: 'frame_id']
browser.driver.switch_to.frame(frame_element)

# Does not pass as expected:
expect {browser.driver.switch_to.frame(frame_element)}.to 
raise_error(Selenium::WebDriver::Error::NoSuchFrameError)

Actual Result: 
Selenium::WebDriver::Error::UnknownError - unknown error: Runtime.evaluate 
threw exception: Error: element is not attached to the page document   (Session 
info: chrome=38.0.2125.111)   (Driver info: 
chromedriver=2.9.248304,platform=Linux 3.13.0-24-generic x86_64)

HTML:
<body>
    <iframe src="iframe_source.html" id="frame_id"></iframe>
</body>

Original issue reported on code.google.com by titusfor...@gmail.com on 30 Oct 2014 at 11:09

GoogleCodeExporter commented 9 years ago
According to Selenium 
http://docs.seleniumhq.org/exceptions/stale_element_reference.jsp

The Element is not Attached to the DOM
A common technique used for simulating a tabbed UI in a web app is to prepare 
DIVs for each tab, but only attach one at a time, storing the rest in 
variables. In this case, it's entirely possible that your code might have a 
reference to an element that is no longer attached to the DOM (that is, that 
has an ancestor which is "document.documentElement").
If WebDriver throws a stale element exception in this case, even though the 
element still exists, the reference is lost. You should discard the current 
reference you hold and replace it, possibly by locating the element again once 
it is attached to the DOM.

Original comment by andrewch...@chromium.org on 18 Nov 2014 at 9:06

GoogleCodeExporter commented 9 years ago
Ah, it isn't stale so much as no longer in the context of the driver, (which 
also means it can't be located again), but this amounts to the same thing. I 
need to implement what I'm doing differently.

This can be closed. Thanks.

Original comment by titusfor...@gmail.com on 18 Nov 2014 at 9:25

GoogleCodeExporter commented 9 years ago

Original comment by andrewch...@chromium.org on 18 Nov 2014 at 10:10

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:26