Java Code Examples for com.gargoylesoftware.htmlunit.html.HtmlForm#removeChild()
The following examples show how to use
com.gargoylesoftware.htmlunit.html.HtmlForm#removeChild() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CsrfIT.java From krazo with Apache License 2.0 | 6 votes |
/** * Retrieves a form, removes CSRF hidden field and attempts to submit. Should * result in a 403 error. * * @throws Exception an error occurs or validation fails. */ @Test public void testFormFail() throws Exception { HtmlPage page1 = webClient.getPage(webUrl + "resources/csrf"); HtmlForm form = (HtmlForm) page1.getDocumentElement().getElementsByTagName("form").get(0); // Remove hidden input field to cause a CSRF validation failure HtmlElement input = form.getElementsByTagName("input").get(1); form.removeChild(input); // Submit form - should fail HtmlSubmitInput button = (HtmlSubmitInput) form.getElementsByTagName("input").get(0); try { button.click(); fail("CSRF validation should have failed!"); } catch (FailingHttpStatusCodeException e) { // falls through } }
Example 2
Source File: CsrfIT.java From ozark with Apache License 2.0 | 6 votes |
/** * Retrieves a form, removes CSRF hidden field and attempts to submit. Should * result in a 403 error. * * @throws Exception an error occurs or validation fails. */ @Test public void testFormFail() throws Exception { HtmlPage page1 = webClient.getPage(webUrl + "resources/csrf"); HtmlForm form = (HtmlForm) page1.getDocumentElement().getHtmlElementsByTagName("form").get(0); // Remove hidden input field to cause a CSRF validation failure HtmlElement input = form.getHtmlElementsByTagName("input").get(1); form.removeChild(input); // Submit form - should fail HtmlSubmitInput button = (HtmlSubmitInput) form.getHtmlElementsByTagName("input").get(0); try { button.click(); fail("CSRF validation should have failed!"); } catch (FailingHttpStatusCodeException e) { // falls through } }
Example 3
Source File: CsrfIT.java From ozark with Apache License 2.0 | 6 votes |
/** * Retrieves a form, removes CSRF hidden field and attempts to submit. Should * result in a 403 error. * * @throws Exception an error occurs or validation fails. */ @Test public void testFormFail() throws Exception { HtmlPage page1 = webClient.getPage(webUrl + "resources/csrf"); HtmlForm form = (HtmlForm) page1.getDocumentElement().getHtmlElementsByTagName("form").get(0); // Remove hidden input field to cause a CSRF validation failure HtmlElement input = form.getHtmlElementsByTagName("input").get(1); form.removeChild(input); // Submit form - should fail HtmlSubmitInput button = (HtmlSubmitInput) form.getHtmlElementsByTagName("input").get(0); try { button.click(); fail("CSRF validation should have failed!"); } catch (FailingHttpStatusCodeException e) { // falls through } }