Package com.gistlabs.mechanize.document

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


  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");
View Full Code Here


  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());
View Full Code Here

  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");
  }

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

    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());
  }

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

  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");
  }

  @Test
  public void testSimpleFileUpload() throws Exception {
View Full Code Here

    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").method("post").id("form").enctype("multipart/form-data").addFileInput("fileUpload", "")));
    addPageRequest("POST", "http://test.com/form", newHtml("OK", ""));

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

    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").method("post").id("form").enctype("multipart/form-data").addFileInput("fileUpload", null)));
    addPageRequest("POST", "http://test.com/form", newHtml("OK", ""));

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

    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }
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.