Package com.gistlabs.mechanize.document

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


    String manageKindleUrl = "http://www.amazon.com/gp/digital/fiona/manage/ref=gno_yam_myk";
    AbstractDocument signinPage = agent.get(manageKindleUrl);

    debug(signinPage);

    Form form = signinPage.forms().get(0);
    form.get("email").setValue(username);
    ((Checkable) form.get("ap_signin_existing_radio")).setChecked(true);
    form.get("password").setValue(password);
    Resource managePage = form.submit();
View Full Code Here


  @Test
  public void testSearchingWikipediaForAngelaMerkelInGermanLanguageUtilizingSelectAndTextInput() {
    Mechanize agent = new MechanizeAgent();
    AbstractDocument page = agent.get("http://www.wikipedia.org");
    Form form = page.forms().find(".search-form");
    form.findSelect(byIdOrName("language")).getOption("de").select();
    form.findSearch(byIdOrName("search")).set("Angela Merkel");
    Resource response = form.findSubmitButton(byIdOrName("go")).submit();
    assertTrue(response.getTitle().startsWith("Angela Merkel"));
  }
View Full Code Here

    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form")));
    addPageRequest("http://test.com/form", newHtml("OK", ""));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    Resource response = form.submit();
    assertEquals("OK", response.getTitle());
    assertFalse(form.isDoPost());
  }
View Full Code Here

    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form", "post").id("form")));
    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());
    assertTrue(form.isDoPost());
  }
View Full Code Here

    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").id("form").addText("text", null)));
    addPageRequest("http://test.com/form?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
View Full Code Here

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

  @Test
View Full Code Here

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

  @Test
View Full Code Here

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

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

        .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

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.