use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.
the class HtmlUnitServerTest method shouldStoreResultViaJavaScriptCallWithoutUIAsync.
@Test
public void shouldStoreResultViaJavaScriptCallWithoutUIAsync() throws Exception {
File jsonFile = new File(getReportDir() + "/directory-no-ui-cb/jscoverage.json");
if (jsonFile.exists())
jsonFile.delete();
HtmlPage page = webClient.getPage("http://localhost:9001/example/index.html");
page.executeJavaScript("jscoverage_report('directory-no-ui-cb', function(response){});");
webClient.waitForBackgroundJavaScript(100);
String json = ioUtils.toString(jsonFile);
assertThat(json, containsString("/script.js"));
page = webClient.getPage("file:///" + new File(getReportDir() + "/directory-no-ui-cb/jscoverage.html").getAbsolutePath());
verifyTotal(webClient, page, 15);
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.
the class HtmlUnitServerTest method shouldWorkWithServerIFrameByNavigationButtons.
@Test
public void shouldWorkWithServerIFrameByNavigationButtons() throws Exception {
HtmlPage page = webClient.getPage("http://localhost:9001/jscoverage.html");
((HtmlInput) page.getHtmlElementById("location")).setValueAttribute("http://localhost:9001/example/index.html");
page.getHtmlElementById("openInFrameButton").click();
webClient.waitForBackgroundJavaScript(100);
verifyTotal(webClient, page, 15);
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.
the class HtmlUnitServerTest method testFileUpload.
private void testFileUpload(String postFile) throws IOException {
HtmlPage page = webClient.getPage("http://localhost:9001/example/upload.html");
((HtmlInput) page.getHtmlElementById("uploader")).setValueAttribute(postFile);
page = page.getHtmlElementById("submitButton").click();
String data = page.getHtmlElementById("postData").getTextContent();
assertThat(data, containsString("Line 1\nLine 2"));
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.
the class HtmlUnitServerTest method shouldStoreResultViaJavaScriptCallWithoutUI.
@Test
public void shouldStoreResultViaJavaScriptCallWithoutUI() throws Exception {
File jsonFile = new File(getReportDir() + "/directory-no-ui/jscoverage.json");
if (jsonFile.exists())
jsonFile.delete();
HtmlPage page = webClient.getPage("http://localhost:9001/example/index.html");
page.executeJavaScript("jscoverage_report('directory-no-ui');");
webClient.waitForBackgroundJavaScript(2000);
String json = ioUtils.toString(jsonFile);
assertThat(json, containsString("/script.js"));
page = webClient.getPage("file:///" + new File(getReportDir() + "/directory-no-ui/jscoverage.html").getAbsolutePath());
verifyTotal(webClient, page, 15);
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.
the class HtmlUnitServerTest method testWorkInInvertedMode.
protected void testWorkInInvertedMode(int branchPercentage1, int branchPercentage2, int functionPercentage1, int functionPercentage2) throws IOException {
HtmlPage page = webClient.getPage("http://localhost:9001/example/index.html");
page.getHtmlElementById("launchJSCover").click();
webClient.waitForBackgroundJavaScript(100);
WebWindow webWindow = webClient.getWebWindowByName("JSCoverInvertedMode");
HtmlPage jsCoverPage = (HtmlPage) webWindow.getEnclosedPage();
verifyTotal(webClient, jsCoverPage, 15, branchPercentage1, functionPercentage1);
page.getHtmlElementById("radio3").click();
webClient.waitForBackgroundJavaScript(100);
jsCoverPage.executeJavaScript("jscoverage_recalculateSummaryTab();");
webClient.waitForBackgroundJavaScript(500);
verifyTotal(webClient, jsCoverPage, 73, branchPercentage2, functionPercentage2);
}
Aggregations