On Sep 30, 2:12 pm, Talwinder singh <
talwindersi...@gmail.com> wrote:
> Hi Daniel Wagner,
>
> I tried this also, it works fine if i have only one level of frames in
> a tree, but it doesn't work if i have multilevel frames and iframes,
> everytime i do switchTo().defaultcontent() , it takes driver to the
> root of the tree which is not what i want, i want it to just shift to
> the parent frame node so that i can traverse other branch nodes of
> that tree node.
>
I have the same problem. It is exacerbated by the problem that
WebDriver seems to forget its cache of elements when switching frames
so any WebElements you might have kept around are suddenly invalid
after switching frames (eg: if you try to save the WebElement of the
parent iframe and then switch back to it using
driver.switchTo().frame(parentFrame) => StaleElementException).
In the end I have solved this in the ugliest manner; I store the path
through the tree of frames to the parent frame in terms of a list of
iframe indices. Then I can get back to the parent with
defaultContent() and a series of switchTo().frame(index) calls to
traverse the path.
I would love to know if there is a better way!
Cheers,
Simon