MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / iFrame

Method iFrame

src/test/java/org/htmlunit/WebClient8Test.java:133–159  ·  view source on GitHub ↗

@throws Exception if something goes wrong

()

Source from the content-addressed store, hash-verified

131 * @throws Exception if something goes wrong
132 */
133 @Test
134 public void iFrame() throws Exception {
135 final String html = DOCTYPE_HTML
136 + "<html>\n"
137 + "<head><title>foo</title></head>\n"
138 + "<body>\n"
139 + " <iframe id='tester' src='second.html'></iframe>\n"
140 + "</body></html>";
141
142 final String html2 = DOCTYPE_HTML
143 + "<html>\n"
144 + "<head><title>frame</title></head>\n"
145 + "<body>\n"
146 + "</body></html>";
147
148 try (WebClient webClient = new WebClient(getBrowserVersion(), false, null, -1)) {
149 final MockWebConnection webConnection = getMockWebConnection();
150 webConnection.setResponse(URL_FIRST, html);
151 webConnection.setDefaultResponse(html2);
152 webClient.setWebConnection(webConnection);
153
154 final HtmlPage page = webClient.getPage(URL_FIRST);
155
156 final HtmlInlineFrame iFrame = (HtmlInlineFrame) page.getElementById("tester");
157 assertEquals("frame", ((HtmlPage) iFrame.getEnclosedWindow().getEnclosedPage()).getTitleText());
158 }
159 }
160
161 /**
162 * @throws Exception if something goes wrong

Callers

nothing calls this directly

Calls 11

setResponseMethod · 0.95
setDefaultResponseMethod · 0.95
getElementByIdMethod · 0.95
getMockWebConnectionMethod · 0.80
setWebConnectionMethod · 0.80
getEnclosedWindowMethod · 0.80
getPageMethod · 0.65
getEnclosedPageMethod · 0.65
getBrowserVersionMethod · 0.45
assertEqualsMethod · 0.45
getTitleTextMethod · 0.45

Tested by

no test coverage detected