Search in sources :

Example 46 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage 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 47 with HtmlPage

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

the class UserTest method testLinkWithParam.

@Test
public void testLinkWithParam() throws IOException {
    HtmlAnchor anchor = (HtmlAnchor) page.getElementById("link2");
    assertTrue(anchor.getHrefAttribute().contains("faces/login.xhtml"));
    assertTrue(anchor.getHrefAttribute().contains("?name=Jack"));
    assertEquals("Login2", anchor.asText());
    HtmlPage output = anchor.click();
    assertEquals("HTTP GET (Login)", output.getTitleText());
}
Also used : HtmlAnchor(com.gargoylesoftware.htmlunit.html.HtmlAnchor) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 48 with HtmlPage

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

the class UserTest method testLink.

@Test
public void testLink() throws IOException {
    HtmlAnchor anchor = (HtmlAnchor) page.getElementById("link1");
    assertTrue(anchor.getHrefAttribute().contains("faces/login.xhtml"));
    assertEquals("Login1", anchor.asText());
    HtmlPage output = anchor.click();
    assertEquals("HTTP GET (Login)", output.getTitleText());
}
Also used : HtmlAnchor(com.gargoylesoftware.htmlunit.html.HtmlAnchor) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 49 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage 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 50 with HtmlPage

use of com.gargoylesoftware.htmlunit.html.HtmlPage 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)

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