Examples of AbstractDocument


Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testSimpleLoginFormWithTextAndPasswordAndSubmitButtonSubmittingByPressingEnter() {
    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

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  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());

    form.findCheckbox(byIdOrName("box"), "value1").check();
    form.findCheckbox(byIdOrName("box"), "value2").uncheck();
    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test(expected = UnsupportedOperationException.class)
  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");
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testRadioButtonForm() {
    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());
   
    assertEquals(3, form.findAll(byIdOrName("button"), RadioButton.class).size());

    form.findRadioButton(byIdOrName("button"), "value3").check();
    assertFalse(form.findRadioButton(byIdOrName("button"), "value1").isChecked());
    assertFalse(form.findRadioButton(byIdOrName("button"), "value2").isChecked());
    assertTrue(form.findRadioButton(byIdOrName("button"), "value3").isChecked());
    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test(expected = UnsupportedOperationException.class)
  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");
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  public void testSingleElementSelect() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").beginSelect("person").addOption("Peter", "1").addOption("John", "2").addSelectedOption("Susanna", "3").end()));
    addPageRequest("http://test.com/form?person=1", newHtml("OK", ""));
    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    Select select = form.findSelect(byIdOrName("person"));
    assertFalse(select.isMultiple());
    assertEquals(3, select.getOptions().size());
   
    Option peter = select.getOption("Peter");
    assertEquals("Peter", peter.getText());
    assertEquals("1", peter.getValue());
    assertFalse(peter.isSelected());
   
    Option john = select.getOption("John");
    assertEquals("John", john.getText());
    assertEquals("2", john.getValue());
    assertFalse(john.isSelected());
   
    assertTrue(select.getOption("Susanna").isSelected());

    peter.select();
    assertTrue(peter.isSelected());
    assertFalse(john.isSelected());
    assertFalse(select.getOption("Susanna").isSelected());
    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  public void testMultipleElementSelect() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").beginMultiSelect("person").addOption("Peter", "1").addSelectedOption("John", "2").addOption("Susanna", "3").end()));
    addPageRequest("http://test.com/form?person=2&person=3", newHtml("OK", ""));
    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    Select select = form.findSelect(byIdOrName("person"));
   
    assertTrue(select.isMultiple());
    assertFalse(select.getOption("Peter").isSelected());
    assertTrue(select.getOption("John").isSelected());
    assertFalse(select.getOption("Susanna").isSelected());
    assertEquals(3, select.getOptions().size());

    select.getOption("Peter").select();
    assertTrue(select.getOption("Peter").isSelected());
    assertTrue(select.getOption("John").isSelected());
    assertFalse(select.getOption("Susanna").isSelected());

    select.getOption("Susanna").select();
    select.getOption("Peter").unselect();
    assertFalse(select.getOption("Peter").isSelected());
    assertTrue(select.getOption("John").isSelected());
    assertTrue(select.getOption("Susanna").isSelected());

    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test(expected = UnsupportedOperationException.class)
  public void testSettingValueOfSelectFails() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").beginSelect("person").addOption("Peter", "1").addOption("John", "2").addSelectedOption("Susanna", "3").end()));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    form.findSelect(byIdOrName("person")).setValue("shouldFail");
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testImageToSubmitForm() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addSubmitImage("submitImage", "value")));
    addPageRequest("http://test.com/form?submitImage=value&submitImage.x=20&submitImage.y=10", newHtml("OK", ""));

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

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test(expected = UnsupportedOperationException.class)
  public void testSettingValueOfSubmitImageFails() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addSubmitImage("submitImage", "value")));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    form.findSubmitImage(byIdOrName("submitImage")).setValue("shouldFail");
  }
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.