Examples of AbstractDocument


Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testSimpleInputWithDefaultText() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addText("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());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  public void testSimpleInputSettingValueToValueBiggerThanMaxLengthWillGetAutomaticallyTruncated() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addText("text", null, 5)));
    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    form.find(byIdOrName("text")).set("123456789");
    assertEquals("12345", form.get("text").get());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testEmailInputFieldWithNoText() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addInput("mail", "email", null)));
    addPageRequest("http://test.com/form?mail=", newHtml("OK", ""));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    FormElement email = form.find(byIdOrName("mail"));
    assertTrue(email instanceof Email);
    assertSame(email, form.findEmail(byName("mail")));
    assertSame(email, form.findAll(byName("mail"), Email.class).get(0));
    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testUnrecognizedInputFieldWithNoText() {
    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addInput("unknown", "unknownType", null)));
    addPageRequest("http://test.com/form?unknown=test", newHtml("OK", ""));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    FormElement unknown = form.find(byName("unknown"));
    assertNotNull(unknown);
    assertTrue(unknown instanceof FormElement);
    unknown.setValue("test");
    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

    String newHtml = newHtml("Test Page", newForm("form").id("form")
        .addRaw("<input type=\"text\" class=\"txt\" name=\"login\" size=\"30\" onfocus=\"hlFF(this, true);\" onblur=\"hlFF(this);\">"));
    addPageRequest("http://test.com",
        newHtml);

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    FormElement login = form.find(byIdOrName("login"));
    assertNotNull(login);
    assertTrue(login instanceof FormElement);
    login.setValue("test");
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testTextAreaInputWithDefaultText() {
    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());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

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

Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testHiddenInput() {
    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());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

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

Examples of com.gistlabs.mechanize.document.AbstractDocument

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