# 5.7. Nest Frames

```java
public class NestFramesTest {
    WebDriver driver;

    @BeforeClass
    void setUp() {
        driver = new ChromeDriver();
        driver.get("https://the-internet.herokuapp.com/nested_frames"); //original page
    }

    @Test
    void listAllFrames(){
       driver.switchTo().frame("frame-top"); // is frame-top

       driver.switchTo().frame("frame-left"); // is frame-left
       String leftFrame = driver.findElement(By.xpath("html/body")).getText();
        Assert.assertEquals(leftFrame,"LEFT");
        driver.switchTo().parentFrame();// back to parent is frame-top

        driver.switchTo().frame("frame-middle");
        String middleFrame = driver.findElement(By.id("content")).getText();
        Assert.assertEquals(middleFrame,"MIDDLE");
        driver.switchTo().parentFrame(); // back to parent is frame-top

        driver.switchTo().frame("frame-right");
        String rightFrame = driver.findElement(By.xpath("html/body")).getText();
        Assert.assertEquals(rightFrame,"RIGHT");
        driver.switchTo().parentFrame();// back to parent is frame-top

        driver.switchTo().parentFrame();// back to parent is original page
        driver.switchTo().frame("frame-bottom");
        String bottomFrame = driver.findElement(By.xpath("html/body")).getText();
        Assert.assertEquals(bottomFrame,"BOTTOM");
    }

    @AfterClass
    void tearDown(){
        driver.quit();
    }
}
```

�


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tvn.gitbook.io/selenium-java/examples/nest-frames.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
