Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlElement


     */
    protected HtmlBody body() throws Exception {

        Iterator elements = page.getAllHtmlChildElements();
        while (elements.hasNext()) {
            HtmlElement element = (HtmlElement) elements.next();
            if (element instanceof HtmlBody) {
                return ((HtmlBody) element);
            }
        }
        return (null);
View Full Code Here


     */
    protected HtmlHead head() throws Exception {

        Iterator elements = page.getAllHtmlChildElements();
        while (elements.hasNext()) {
            HtmlElement element = (HtmlElement) elements.next();
            if (element instanceof HtmlHead) {
                return ((HtmlHead) element);
            }
        }
        return (null);
View Full Code Here

     * <p>Validate pristine instance of the test page.</p>
     */
    public void testPristine() throws Exception {

        HtmlForm form = null;
        HtmlElement text = null;
        HtmlSubmitInput submit = null;

        // setUp() should have put us on the page
        assertEquals("View Controller Test", title());
        form = (HtmlForm) element("form");
        assertNotNull(form);
        text = element("form:text");
        assertNotNull(text);
        submit = (HtmlSubmitInput) element("form:submit");
        assertNotNull(submit);

        // Check the expected contents of the "text" element on
        // an initial request for this page.  Note that we cannot
        // check for the destroy event, because it has not yet occurred
        // when the value binding expression in our test page is evaluated
        assertEquals("init/false/prerender/false/", text.asText());

    }
View Full Code Here

        HtmlSubmitInput submit = (HtmlSubmitInput) element("form:submit");
        submit(submit);

        // Validate the redispayed content
        assertEquals("View Controller Test", title());
        HtmlElement text = element("form:text");
        assertNotNull(text);
        assertEquals("init/true/preprocess/true/submit/true/prerender/true/", text.asText());

    }
View Full Code Here

     */
    public void testDouble() throws Exception {

        // Save the current page so we can resubmit it
        HtmlPage save = this.page;
        HtmlElement message = null;
        String text = null;

        // setUp() should have put us on the page
        assertEquals("Shale Token Test", title());

        // Fill in the required value and submit the form
        HtmlTextInput value = (HtmlTextInput) element("form:value");
        value.setValueAttribute("Value");
        HtmlSubmitInput submit = (HtmlSubmitInput) element("form:submit");
        submit(submit);

        // Restore the saved page and submit it again
        this.page = save;
        value = (HtmlTextInput) element("form:value");
        value.setValueAttribute("Value");
        submit = (HtmlSubmitInput) element("form:submit");
        submit(submit);

        // Verify we stayed on the same page with appropriate error messages
        assertEquals("Shale Token Test", title());
        HtmlElement messages = element("form:messages");
        assertNotNull(messages);
        text = messages.asText();
        assertTrue(text.indexOf("Invalid resubmit (summary)") != -1);
        message = element("form:valueMessage");
        assertNull(message);
        message = element("form:tokenMessage");
        assertNotNull(message);
View Full Code Here

     * <p>Validate pristine instance of the "Token" test page.</p>
     */
    public void testPristine() throws Exception {

        HtmlForm form = null;
        HtmlElement message = null;
        HtmlElement messages = null;
        HtmlHiddenInput token = null;
        HtmlSubmitInput submit = null;
        HtmlTextInput value = null;

        // setUp() should have put us on the page
View Full Code Here

     */
    public void testValidate() throws Exception {

        // Save the current page so we can resubmit it
        HtmlPage save = this.page;
        HtmlElement message = null;
        String text = null;

        // setUp() should have put us on the page
        assertEquals("Shale Token Test", title());

        // Submit the form without setting the value
        HtmlSubmitInput submit = (HtmlSubmitInput) element("form:submit");
        submit(submit);

        // Verify we stayed on the same page with appropriate error messages
        assertEquals("Shale Token Test", title());
        HtmlElement messages = element("form:messages");
        assertNotNull(messages);
        // Cannot accurately test for implementation-defined message
        message = element("form:valueMessage");
        assertNotNull(message);
        // Cannot accurately test for implementation-defined message
View Full Code Here

        submit = (HtmlSubmitInput) element("form:submit");
        submit(submit);

        // Verify we stayed on the same page with appropriate error messages
        assertEquals("Shale Token Test", title());
        HtmlElement messages = element("form:messages");
        assertNotNull(messages);
        String text = messages.asText();
        assertTrue(text.indexOf("Invalid resubmit (summary)") != -1);
        HtmlElement message = element("form:valueMessage");
        assertNull(message);
        message = element("form:tokenMessage");
        assertNotNull(message);
        assertTrue(message.asText().indexOf("Invalid resubmit (detail)") != -1);

    }
View Full Code Here

    @Test
    public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
        HtmlPage page = (HtmlPage)new WebClient().getPage("http://localhost:8085/helloworld-webapp");
        Iterator<?> ss = page.getAllHtmlChildElements().iterator();
        while(ss.hasNext()) {
            HtmlElement htmlElement = (HtmlElement) ss.next();
            if( htmlElement instanceof HtmlParagraph) {
                assertEquals("Hello world", htmlElement.asText());
                break;
            }
        }
    }
View Full Code Here

     */
    protected HtmlBody body() throws Exception {

        Iterator elements = page.getAllHtmlChildElements();
        while (elements.hasNext()) {
            HtmlElement element = (HtmlElement) elements.next();
            if (element instanceof HtmlBody) {
                return ((HtmlBody) element);
            }
        }
        return (null);
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.html.HtmlElement

Copyright © 2018 www.massapicom. 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.