Package com.gistlabs.mechanize.document

Examples of com.gistlabs.mechanize.document.AbstractDocument.forms()


    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addTextArea("text", "Text")));
    addPageRequest("http://test.com/form?text=Text", newHtml("OK", ""));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }

  public void testTextAreaInputWithChangedValue() {
View Full Code Here


    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addTextArea("text", "Text")));
    addPageRequest("http://test.com/form?text=differentText", newHtml("OK", ""));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    form.findTextArea(byIdOrName("text")).setValue("differentText");
    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }
View Full Code Here

    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addHidden("hidden", "Text")));
    addPageRequest("http://test.com/form?hidden=Text", newHtml("OK", ""));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }

  @Test(expected = UnsupportedOperationException.class)
View Full Code Here

  public void testSettingValueOfSubmitButtonFails() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addSubmitButton("button", "Text")));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    form.find(byIdOrName("button")).setValue("shouldFail");
  }

  @Test
  public void testSimpleLoginFormWithTextAndPasswordAndSubmitButtonSubmittingByButton() {
View Full Code Here

    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addText("user", null).addPassword("pass", null).addSubmitButton("submit", "pressed")));
    addPageRequest("http://test.com/form?user=username&pass=password&submit=pressed", newHtml("OK", ""));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    form.find(byIdOrName("user")).setValue("username");
    form.find(byIdOrName("pass")).setValue("password");
    AbstractDocument response = form.findSubmitButton(byIdOrName("submit")).submit();
    assertEquals("OK", response.getTitle());
  }
View Full Code Here

    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addText("user", null).addPassword("pass", null).addSubmitButton("submit", "pressed")));
    addPageRequest("http://test.com/form?user=username&pass=password", newHtml("OK", ""));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    form.find(byIdOrName("user")).setValue("username");
    form.find(byIdOrName("pass")).setValue("password");
    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }
View Full Code Here

  public void testCheckboxForm() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addCheckbox("box", "value1").addCheckedCheckbox("box", "value2").addCheckedCheckbox("box", "value3")));
    addPageRequest("http://test.com/form?box=value1&box=value3", newHtml("OK", ""));
    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    assertFalse(form.findCheckbox(byIdOrName("box"), "value1").isChecked());
    assertTrue(form.findCheckbox(byIdOrName("box"), "value2").isChecked());
    assertTrue(form.findCheckbox(byIdOrName("box"), "value3").isChecked());
    assertEquals(3, form.findAll(byIdOrName("box"), Checkbox.class).size());
View Full Code Here

  public void testSettingValueOfCheckboxFails() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addCheckbox("box", "value")));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    form.findCheckbox(byIdOrName("box")).setValue("shouldFail");
  }

  @Test
  public void testRadioButtonForm() {
View Full Code Here

    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addRadioButton("button", "value1").
            addCheckedRadioButton("button", "value2").addRadioButton("button", "value3")));
    addPageRequest("http://test.com/form?button=value3", newHtml("OK", ""));
    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");

    assertFalse(form.findRadioButton(byIdOrName("button"), "value1").isChecked());
    assertTrue(form.findRadioButton(byIdOrName("button"), "value2").isChecked());
    assertFalse(form.findRadioButton(byIdOrName("button"), "value3").isChecked());
   
View Full Code Here

  public void testSettingValueOfRadioButtonFails() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addRadioButton("button", "value")));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    form.findRadioButton(byIdOrName("button")).setValue("shouldFail");
  }

  @Test
  public void testSingleElementSelect() {
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.