Package com.gistlabs.mechanize

Examples of com.gistlabs.mechanize.Mechanize


*/
public class CookiesTest {

  @Test
  public void testCookieRepresentiveIsTheSame() {
    Mechanize agent = new MechanizeAgent();
    Cookie cookie = agent.cookies().addNewCookie("ID", "Value", ".test.com");
    assertSame(cookie, agent.cookies().get("ID", ".test.com"));
    assertSame(cookie, agent.cookies().get("ID", ".test.com"));
  }
View Full Code Here


    assertSame(cookie, agent.cookies().get("ID", ".test.com"));
  }

  @Test
  public void testRemovingASingleCookie() {
    Mechanize agent = new MechanizeAgent();
    Cookie cookie1 = agent.cookies().addNewCookie("ID", "MyID", ".wikipedia.org");
    Cookie cookie2 = agent.cookies().addNewCookie("ID2", "MySecondID", "wikipedia.org");

    agent.cookies().remove(cookie1);
    assertFalse(agent.cookies().getAll().contains(cookie1));
    assertTrue(agent.cookies().getAll().contains(cookie2));
  }
View Full Code Here

  //@org.junit.Test
  public void testRedirect() throws IOException {
    String username = "";
    String password = "";
    Mechanize agent = new MechanizeAgent(buildClient());

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

*/
public class WikipediaSearchForAngelaMerkelAndDownloadingImagesIT {

  @Test
  public void testLoadWikipediaIndexPage() {
    Mechanize agent = new MechanizeAgent();
    AbstractDocument page = agent.get("http://www.wikipedia.org");
    assertNotNull(page);
    assertTrue(page.size() > 10000);
    Links links = page.links();
    assertTrue(links.size() > 10);
    assertNotNull(links.find("*[title*='English']"));
 
View Full Code Here

    assertNotNull(links.find("*[title*='English']"));
  }

  @Test
  public void testClickingEnglishWikipediaVersionLink() {
    Mechanize agent = new MechanizeAgent();
    AbstractDocument page = agent.get("http://www.wikipedia.org");
    assertNotNull(page);
    assertTrue(page.size() > 10000);
    Links links = page.links();
    assertTrue(links.size() > 10);
    Link link = links.find("*[title*='English']");
 
View Full Code Here

    assertEquals("Wikipedia, the free encyclopedia", englishPage.getTitle());
  }

  @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

* @author Martin Kersten<Martin.Kersten.mk@gmail.com>
*/
public class CookiesTest {
  //@Test // no longer working
  public void xtestWikipediaSendsNoCookies() {
    Mechanize agent = new MechanizeAgent();

    agent.get("http://www.wikipedia.org");
    assertEquals(0, agent.cookies().getCount());
  }
View Full Code Here

*/
public class GoogleSearchForMechanizeJavaIT {

  @Test
  public void testGooglePageSearchForm() {
    Mechanize agent = new MechanizeAgent();
    AbstractDocument page = agent.get("http://www.google.com");
    Form form = page.form("f");
    form.get("q").set("mechanize java");
    Resource response = form.submit();
    assertTrue(response.getTitle().startsWith("mechanize java"));
  }
View Full Code Here

  String shortUrl = "http://goo.gl/daal8";
  String longUrl = "http://gistlabs.com/software/mechanize-for-java/";

  @Test
  public void testShortUrl() throws JSONException {
    Mechanize agent = new MechanizeAgent();
    HtmlDocument html = agent.get(shortUrl);
    assertEquals(longUrl, html.getUri());
  }
View Full Code Here

*/
public class AndroidJsonApiIT {

  @Test
  public void testAndroidJsonApiDemo() throws JSONException {
    Mechanize agent = new MechanizeAgent();
    JsonDocument page = (JsonDocument) agent.get("http://api.androidhive.info/contacts/");

    List<? extends JsonNode> contacts = page.getRoot().getChildren("contacts");
    assertNotNull(contacts);
    assertEquals("c200", contacts.get(0).getAttribute("id"));
  }
View Full Code Here

TOP

Related Classes of com.gistlabs.mechanize.Mechanize

Copyright © 2018 www.massapicom. 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.