Example I

Getting the page inside <frame> element or <iframe> element can be done by using HtmlPage.getFrames().
Suppose you have the following page:

    <iframe src="two.html">

You can use the following code to get the content of two.html:

final List<FrameWindow> window = page.getFrames();
final HtmlPage pageTwo = (HtmlPage) window.get(0).getEnclosedPage();

Example II

Another example that navigates API docs to get a desired page of a class:

final WebClient client = new WebClient();
final HtmlPage mainPage = client.getPage("http://htmlunit.sourceforge.net/apidocs/index.html");

To get the page of the first frame (at upper left) and click the sixth link:

final HtmlPage packageListPage = (HtmlPage) mainPage.getFrames().get(0).getEnclosedPage();

To get the page of the frame named 'packageFrame' (at lower left) and click the second link:

final HtmlPage pakcagePage = (HtmlPage) mainPage.getFrameByName("packageFrame").getEnclosedPage();

To get the page of the frame named 'classFrame' (at right):

final HtmlPage classPage = (HtmlPage) mainPage.getFrameByName("classFrame").getEnclosedPage();