use of com.gargoylesoftware.htmlunit.html.HtmlPage in project nodejs-plugin by jenkinsci.
the class NodeJSInstallationTest method test_persist_of_nodejs_installation.
/**
* Simulates the addition of the new NodeJS via UI and makes sure it works
* and persistent file was created.
*/
@Test
@Issue("JENKINS-41535")
public void test_persist_of_nodejs_installation() throws Exception {
File jenkinsHome = r.jenkins.getRootDir();
File installationsFile = new File(jenkinsHome, NodeJSInstallation.class.getName() + ".xml");
assertFalse("NodeJS installations file already exists", installationsFile.exists());
HtmlPage p = getConfigurePage();
HtmlForm f = p.getFormByName("config");
HtmlButton b = r.getButtonByCaption(f, "Add NodeJS");
b.click();
r.findPreviousInputElement(b, "name").setValueAttribute("myNode");
r.findPreviousInputElement(b, "home").setValueAttribute("/tmp/foo");
r.submit(f);
verify();
assertTrue("NodeJS installations file has not been saved", installationsFile.exists());
// another submission and verify it survives a roundtrip
p = getConfigurePage();
f = p.getFormByName("config");
r.submit(f);
verify();
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.
the class HtmlUnitLocalStorageTest method shouldStoreCoverageDataInLocalStorage.
@Test
public void shouldStoreCoverageDataInLocalStorage() throws IOException, InterruptedException {
webClient.getPage("http://localhost:9001/jscoverage-clear-local-storage.html");
webClient.getPage("http://localhost:9001/" + getTestUrl());
HtmlPage page = webClient.getPage("http://localhost:9001/jscoverage.html");
verifyTotal(page, 15, 0, 0);
clickItem(1, 57, 12, 33);
clickItem(2, 73, 37, 66);
clickItem(3, 84, 62, 66);
clickItem(4, 100, 87, 100);
// page.getHtmlElementById("storeTab").click();
// page.getElementById("storeButton").click();
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.
the class HtmlUnitMergeTest method saveUnloadedJS.
private void saveUnloadedJS() throws IOException {
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage("http://localhost:9001/jscoverage.html");
storeReport(webClient, page);
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.
the class HtmlUnitMergeTest method shouldMergeUnloadedButtonSavedAndJSSavedReports.
@Test
public void shouldMergeUnloadedButtonSavedAndJSSavedReports() throws Exception {
File jsonFile = new File(reportDir + "/jscoverage.json");
if (jsonFile.exists())
jsonFile.delete();
saveUnloadedJS();
saveReportByJavaScript();
saveReportByButton();
String json = ioUtils.toString(jsonFile);
assertThat(json, containsString("/root.js"));
assertThat(json, containsString("/level1/level2/level2.js"));
String url = "file:///" + new File(reportDir + "/jscoverage.html").getAbsolutePath();
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage(url);
webClient.waitForBackgroundJavaScript(1000);
assertEquals("53%", page.getElementById("summaryTotal").getTextContent());
assertEquals("33%", page.getElementById("branchSummaryTotal").getTextContent());
assertEquals("50%", page.getElementById("functionSummaryTotal").getTextContent());
verifyCoverage(page, "/root.js", "80%", "50%", "100%");
verifyCoverage(page, "/root-empty.js", "N/A", "N/A", "N/A");
verifyCoverage(page, "/level1/level1.js", "75%", "50%", "N/A");
verifyCoverage(page, "/level1/level2/level2.js", "0%", "0%", "0%");
verifyCoverage(page, "/level1/level2/level2-empty.js", "N/A", "N/A", "N/A");
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project JSCover by tntim96.
the class HtmlUnitServerTest method shouldStoreResultViaJavaScriptCall.
@Test
public void shouldStoreResultViaJavaScriptCall() throws Exception {
File jsonFile = new File(getReportDir() + "/directory/jscoverage.json");
if (jsonFile.exists())
jsonFile.delete();
HtmlPage page = webClient.getPage("http://localhost:9001/jscoverage.html");
((HtmlInput) page.getHtmlElementById("location")).setValueAttribute("http://localhost:9001/example/index.html");
page.getHtmlElementById("openInWindowButton").click();
webClient.waitForBackgroundJavaScript(100);
verifyTotal(webClient, page, 15);
WebWindow webWindow = webClient.getWebWindowByName("jscoverage_window");
((HtmlPage) webWindow.getEnclosedPage()).executeJavaScript("jscoverage_report('directory');");
webClient.waitForBackgroundJavaScript(2000);
String json = ioUtils.toString(jsonFile);
assertThat(json, containsString("/script.js"));
page = webClient.getPage("file:///" + new File(getReportDir() + "/directory/jscoverage.html").getAbsolutePath());
verifyTotal(webClient, page, 15);
}
Aggregations