Examples of TextPage


Examples of com.gargoylesoftware.htmlunit.TextPage

    @SpecAssertions({ @SpecAssertion(section = "6.7.4", id = "aa") })
    public void testPost() throws Exception {
        WebClient client = new WebClient();

        // begin conversation
        TextPage initialPage = client.getPage(getPath("/begin", null));
        String content = initialPage.getContent();
        assertTrue(content.contains("message: Hello"));
        assertTrue(content.contains("transient: false"));

        String cid = getCid(content);

        // submit a form
        {
            HtmlPage form = client.getPage(url.toString() + "/message.html");
            getFirstMatchingElement(form, HtmlTextInput.class, "message").setValueAttribute("Hola!");
            getFirstMatchingElement(form, HtmlTextInput.class, "cid").setValueAttribute(cid);
            TextPage page = getFirstMatchingElement(form, HtmlSubmitInput.class, "submit").click();

            assertTrue(page.getContent().contains("message: Hola!"));
            assertTrue(page.getContent().contains("cid: [" + cid + "]"));
            assertTrue(page.getContent().contains("transient: false"));
        }

        // verify conversation state
        {
            TextPage page = client.getPage(getPath("/display", cid));
            assertTrue(page.getContent().contains("message: Hola!"));
            assertTrue(page.getContent().contains("cid: [" + cid + "]"));
            assertTrue(page.getContent().contains("transient: false"));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.