use of com.gargoylesoftware.htmlunit.html.HtmlScript in project htmlunit by HtmlUnit.
the class JavaScriptEngineTest method externalScript.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts("got here")
public void externalScript() throws Exception {
final String html = "<html><head><title>foo</title><script src='/foo.js' id='script1'/>\n" + "</head><body>\n" + "<p>hello world</p>\n" + "<form name='form1'>\n" + " <input type='text' name='textfield1' id='textfield1' value='foo' />\n" + " <input type='text' name='textfield2' id='textfield2'/>\n" + "</form>\n" + "</body></html>";
final String jsContent = "alert('got here');\n";
getMockWebConnection().setResponse(new URL(URL_FIRST, "foo.js"), jsContent, "text/javascript");
final HtmlPage page = loadPageWithAlerts(html);
final HtmlScript htmlScript = page.getHtmlElementById("script1");
assertNotNull(htmlScript);
}
Aggregations