Search in sources :

Example 16 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.

the class HtmlUnitServerTest method testIncreaseCoverage.

protected void testIncreaseCoverage(int[] branchPercentages, int[] functionPercentages) throws IOException {
    HtmlPage page = webClient.getPage("http://localhost:9001/jscoverage.html?" + getTestUrl());
    verifyTotal(webClient, page, 15);
    page.getHtmlElementById("browserTab").click();
    HtmlPage frame = (HtmlPage) page.getFrameByName("browserIframe").getEnclosedPage();
    frame.getHtmlElementById("radio1").click();
    page.executeJavaScript("jscoverage_recalculateSummaryTab();");
    verifyTotals(page, 57, branchPercentages[0], functionPercentages[0]);
    frame.getHtmlElementById("radio2").click();
    page.executeJavaScript("jscoverage_recalculateSummaryTab();");
    verifyTotals(page, 73, branchPercentages[1], functionPercentages[1]);
    frame.getHtmlElementById("radio3").click();
    page.executeJavaScript("jscoverage_recalculateSummaryTab();");
    verifyTotals(page, 84, branchPercentages[2], functionPercentages[2]);
    frame.getHtmlElementById("radio4").click();
    page.executeJavaScript("jscoverage_recalculateSummaryTab();");
    verifyTotals(page, 100, branchPercentages[3], functionPercentages[3]);
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage)

Example 17 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.

the class WebDaemonTest method shouldStopDaemon.

@Test
public void shouldStopDaemon() throws Exception {
    HtmlPage page = webClient.getPage("http://localhost:8081/jscoverage.html");
    assertThat(page.getTitleText(), equalTo("JSCover"));
    main.stop();
    server.join(1000);
    assertThat(server.getState(), equalTo(Thread.State.TERMINATED));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 18 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.

the class HtmlUnitUITest method shouldSortFilesByCoverage.

@Test
public void shouldSortFilesByCoverage() throws IOException {
    HtmlPage page = webClient.getPage("file:///" + new File(reportDir + "/jscoverage.html").getAbsolutePath());
    page.getHtmlElementById("summaryTab").click();
    webClient.waitForBackgroundJavaScript(2000);
    page.getHtmlElementById("sortByName").click();
    webClient.waitForBackgroundJavaScript(100);
    sortByField(page, "Line");
    sortByField(page, "Branch");
    sortByField(page, "Function");
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) File(java.io.File) Test(org.junit.Test)

Example 19 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.

the class HtmlUnitUITest method shouldSortFilesByName.

@Test
public void shouldSortFilesByName() throws IOException {
    HtmlPage page = webClient.getPage("file:///" + new File(reportDir + "/jscoverage.html").getAbsolutePath());
    page.getHtmlElementById("summaryTab").click();
    webClient.waitForBackgroundJavaScript(2000);
    page.getHtmlElementById("sortByName").click();
    webClient.waitForBackgroundJavaScript(100);
    Collections.sort(data, byName());
    for (int i = 0; i < data.size(); i++) verifyScriptMatchesRow(data.get(i), ((HtmlTableRow) page.getByXPath("//tbody[@id='summaryTbody']/tr[" + (i + 1) + "]").get(0)));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) File(java.io.File) Test(org.junit.Test)

Example 20 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.

the class HtmlUnitUITest method storeResult.

private static void storeResult() throws IOException {
    WebClient webClient = new WebClient();
    webClient.getOptions().setTimeout(1000);
    HtmlPage page = webClient.getPage("http://localhost:9001/jscoverage.html?index.html");
    page.getHtmlElementById("storeTab").click();
    webClient.waitForBackgroundJavaScript(500);
    page.getHtmlElementById("storeButton").click();
    webClient.waitForBackgroundJavaScript(2000);
    String result = page.getElementById("storeDiv").getTextContent();
    assertThat(result, containsString("Coverage data stored at target"));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) WebClient(com.gargoylesoftware.htmlunit.WebClient)

Aggregations

HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)159 Test (org.junit.Test)114 WebClient (com.gargoylesoftware.htmlunit.WebClient)51 HtmlSubmitInput (com.gargoylesoftware.htmlunit.html.HtmlSubmitInput)25 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)23 HtmlSpan (com.gargoylesoftware.htmlunit.html.HtmlSpan)21 File (java.io.File)17 HtmlInput (com.gargoylesoftware.htmlunit.html.HtmlInput)15 Matchers.containsString (org.hamcrest.Matchers.containsString)13 IOException (java.io.IOException)11 JenkinsRule (org.jvnet.hudson.test.JenkinsRule)10 FreeStyleProject (hudson.model.FreeStyleProject)9 URL (java.net.URL)9 Page (com.gargoylesoftware.htmlunit.Page)8 HtmlTextInput (com.gargoylesoftware.htmlunit.html.HtmlTextInput)7 WebWindow (com.gargoylesoftware.htmlunit.WebWindow)6 DomElement (com.gargoylesoftware.htmlunit.html.DomElement)6 WebRequest (com.gargoylesoftware.htmlunit.WebRequest)5 HtmlButton (com.gargoylesoftware.htmlunit.html.HtmlButton)5 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)5