Search in sources :

Example 1 with HtmlSpan

use of com.gargoylesoftware.htmlunit.html.HtmlSpan in project javaee7-samples by javaee-samples.

the class MyBeanTest method testZipAlphabets.

@Test
public void testZipAlphabets() throws IOException {
    nameInputText.setText("abc");
    ageInputText.setText("20");
    zipInputText.setText("abcde");
    HtmlPage result = button.click();
    HtmlSpan span = (HtmlSpan) result.getElementById("zipMessage");
    assertEquals("must match \"[0-9]{5}\"", span.asText());
}
Also used : HtmlSpan(com.gargoylesoftware.htmlunit.html.HtmlSpan) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 2 with HtmlSpan

use of com.gargoylesoftware.htmlunit.html.HtmlSpan in project javaee7-samples by javaee-samples.

the class MyBeanTest method testAgeLessThan.

@Test
public void testAgeLessThan() throws IOException {
    nameInputText.setText("abc");
    ageInputText.setText("16");
    zipInputText.setText("12345");
    HtmlPage result = button.click();
    HtmlSpan span = (HtmlSpan) result.getElementById("ageMessage");
    assertEquals("must be greater than or equal to 18", span.asText());
}
Also used : HtmlSpan(com.gargoylesoftware.htmlunit.html.HtmlSpan) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 3 with HtmlSpan

use of com.gargoylesoftware.htmlunit.html.HtmlSpan in project javaee7-samples by javaee-samples.

the class MyBeanTest method testZipBoundary.

@Test
public void testZipBoundary() throws IOException {
    nameInputText.setText("abc");
    ageInputText.setText("20");
    zipInputText.setText("12345");
    HtmlPage result = button.click();
    HtmlSpan span = (HtmlSpan) result.getElementById("zipMessage");
    assertEquals("", span.asText());
}
Also used : HtmlSpan(com.gargoylesoftware.htmlunit.html.HtmlSpan) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 4 with HtmlSpan

use of com.gargoylesoftware.htmlunit.html.HtmlSpan in project core by weld.

the class JsfTest method testELWithParameters.

@Test
public void testELWithParameters(@ArquillianResource URL baseURL) throws Exception {
    WebClient client = new WebClient();
    HtmlPage page = client.getPage(new URL(baseURL, "charlie.jsf"));
    page.asXml();
    HtmlSpan oldel = getFirstMatchingElement(page, HtmlSpan.class, "oldel");
    assertNotNull(oldel);
    final String charlie = "Charlie";
    assertEquals(charlie, oldel.asText());
    HtmlSpan newel = getFirstMatchingElement(page, HtmlSpan.class, "newel");
    assertNotNull(newel);
    assertEquals(charlie, newel.asText());
}
Also used : HtmlSpan(com.gargoylesoftware.htmlunit.html.HtmlSpan) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) WebClient(com.gargoylesoftware.htmlunit.WebClient) URL(java.net.URL) Test(org.junit.Test)

Example 5 with HtmlSpan

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

the class HtmlUnitJSTest method shouldTestJavaScript.

@Test
public void shouldTestJavaScript() throws Exception {
    HtmlPage page = webClient.getPage("http://localhost:8081/jscoverage.html?src/test/javascript/spec/suite.html");
    webClient.waitForBackgroundJavaScript(2000);
    // Verify Jasmine test result
    HtmlPage frame = (HtmlPage) page.getFrameByName("browserIframe").getEnclosedPage();
    List<HtmlSpan> passed = frame.getByXPath("//span[contains(@class,'jasmine-passed')]");
    assertThat(passed.size(), equalTo(1));
    assertThat(frame.getByXPath("//span[contains(@class,'jasmine-failed')]").size(), equalTo(0));
    assertThat(frame.getByXPath("//span[contains(@class,'jasmine-skipped')]").size(), equalTo(0));
    assertThat(passed.get(0).asText(), startsWith("15 specs, 0 failures"));
    // Store Report
    frame.executeJavaScript("jscoverage_report();");
    webClient.waitForBackgroundJavaScript(2000);
    // Verify coverage
    page.getHtmlElementById("summaryTab").click();
    webClient.waitForBackgroundJavaScript(2000);
    assertEquals("100%", page.getElementById("summaryTotal").getTextContent());
}
Also used : HtmlSpan(com.gargoylesoftware.htmlunit.html.HtmlSpan) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Aggregations

HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)12 HtmlSpan (com.gargoylesoftware.htmlunit.html.HtmlSpan)12 Test (org.junit.Test)12 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 URL (java.net.URL)1