selenium-webdriver Navigate between multiple frames Frame example


Example

<iframe "id="iframe_Login1">

    <iframe "id="iframe_Login2">
  
        <iframe "id="iframe_Login3">

        </iframe>

    </iframe>

</iframe>

To switch into frame in selenium use swithTo() and frame()method.

driver.switchTo().frame(iframe_Login1); driver.switchTo().frame(iframe_Login2); driver.switchTo().frame(iframe_Login3);

To switch back we can use parentFrame() and defaultContest();

parentFrame() : Change focus to the parent context. If the current context is the top level browsing context, the context remains unchanged.

driver.switchTo().parentFrame();

defaultContent() : Selects either the first frame on the page, or the main document when a page contains iframes.

 driver.switchTo().defaultContent();