Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlPage


        try {
            final String csrfId = String.valueOf(new SecureRandom().nextLong());

            OAuthWebViewData viewData = new OAuthWebViewData(boxClient.getOAuthDataController());
            viewData.setOptionalState(String.valueOf(csrfId));
            final HtmlPage authPage = webClient.getPage(viewData.buildUrl().toString());

            // submit login credentials
            final HtmlForm loginForm = authPage.getFormByName("login_form");
            final HtmlTextInput login = loginForm.getInputByName("login");
            login.setText(configuration.getUserName());
            final HtmlPasswordInput password = loginForm.getInputByName("password");
            password.setText(configuration.getUserPassword());
            final HtmlSubmitInput submitInput = loginForm.getInputByName("login_submit");

            // submit consent
            final HtmlPage consentPage = submitInput.click();
            final HtmlForm consentForm = consentPage.getFormByName("consent_form");
            final HtmlButton consentAccept = consentForm.getButtonByName("consent_accept");

            // disable redirect to avoid loading redirect URL
            webClient.getOptions().setRedirectEnabled(false);
View Full Code Here


                    }
                }
                url = String.format(AUTHORIZATION_URL_WITH_SCOPE, oAuthParams.getClientId(), csrfId,
                    builder.toString(), encodedRedirectUri);
            }
            final HtmlPage authPage = webClient.getPage(url);

            // submit login credentials
            final HtmlForm loginForm = authPage.getFormByName("oauth2SAuthorizeForm");
            final HtmlTextInput login = loginForm.getInputByName("session_key");
            login.setText(oAuthParams.getUserName());
            final HtmlPasswordInput password = loginForm.getInputByName("session_password");
            password.setText(oAuthParams.getUserPassword());
            final HtmlSubmitInput submitInput = loginForm.getInputByName("authorize");
View Full Code Here

        /**
         * Logs in to Hudson.
         */
        public WebClient login(String username, String password) throws Exception {
            HtmlPage page = goTo("/login");
//            page = (HtmlPage) page.getFirstAnchorByText("Login").click();

            HtmlForm form = page.getFormByName("login");
            form.getInputByName("j_username").setValueAttribute(username);
            form.getInputByName("j_password").setValueAttribute(password);
            form.submit(null);
            return this;
        }
View Full Code Here

                throw t[0];
            return r.get(0);
        }

        public HtmlPage search(String q) throws IOException, SAXException {
            HtmlPage top = goTo("");
            HtmlForm search = top.getFormByName("search");
            search.getInputByName("q").setValueAttribute(q);
            return (HtmlPage)search.submit(null);
        }
View Full Code Here

    public void checkComponentSource(URL pageName, String xmlunitPage, By pageElementToTest) throws IOException, SAXException {
        WebClient client = new WebClient();
        client.getOptions().setJavaScriptEnabled(false);

        HtmlPage page = client.getPage(pageName);
        DomElement element;

        String locator = pageElementToTest.toString();
        locator = locator.substring(locator.indexOf(':') + 1).trim();

        if (pageElementToTest instanceof ById) {
            element = page.getElementById(locator);
        } else if (pageElementToTest instanceof ByTagName) {
            element = page.getElementsByTagName(locator).get(0);
        } else {
            throw new IllegalArgumentException("Only id and name are supported");
        }

        String pageCode = element.asXml();
View Full Code Here

    protected Message getErrorMessage() {
        return new Message(2, "error summary", "error description");
    }

    protected HtmlElement getMessageContentElement() {
        HtmlPage page = qunit.getPage();
        HtmlElement htmlElement = (HtmlElement) page.getElementById(MY_MESSAGE);
        assertNotNull(htmlElement);
        return htmlElement;
    }
View Full Code Here

        }
    }

    @Test
    public void testRendering() throws Exception {
        HtmlPage page = environment.getPage("/test.jsf");
        checkRendering(page, 0, TEST_DATA_SIZE);
    }
View Full Code Here

    }

    @Test
    public void testFirst() throws Exception {
        testBean.setFirst(5);
        HtmlPage page = environment.getPage("/test.jsf");
        checkRendering(page, 5, TEST_DATA_SIZE - 5);
    }
View Full Code Here

    }

    @Test
    public void testRows() throws Exception {
        testBean.setRows(6);
        HtmlPage page = environment.getPage("/test.jsf");
        checkRendering(page, 0, 6);
    }
View Full Code Here

        testBean.setRows(10);

        testBean.setSwitchedFirst(15);
        testBean.setSwitchedRows(7);

        HtmlPage page = environment.getPage("/test.jsf");
        checkRendering(page, 0, 10);

        page = (HtmlPage) ((HtmlElement) page.getElementById("form:switchFirstAndRowsLink")).click();

        assertEquals(15, testBean.getFirst());
        assertEquals(7, testBean.getRows());
    }
View Full Code Here

TOP

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

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.