Examples of AbstractDocument


Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  public void testLinkQueryById() {
    addPageRequest("http://test.com",
        newHtml("Test Page", "<a id=\"foo\" href=\"foo.html\">foo</a>"));
   
    AbstractDocument page = agent().get("http://test.com");
    Link link = page.links().find("#foo");
    assertNotNull(link);
    assertEquals("http://test.com/foo.html", link.href());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  public void testLinkQueryByClass() {
    addPageRequest("http://test.com",
        newHtml("Test Page", "<a id=\"foo\" class=\"bar baz\" href=\"foo.html\">foo</a>"));
   
    AbstractDocument page = agent().get("http://test.com");
   
    assertNull(page.links().find(".foo")); // foo class
   
    Link link1 = page.links().find(".bar");
    assertNotNull(link1);
    assertEquals("http://test.com/foo.html", link1.href());

    Link link2 = page.links().find(".baz");
    assertNotNull(link2);
    assertEquals("http://test.com/foo.html", link2.href());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  public void testLinkQueryByNameNotFound() {
    addPageRequest("http://test.com",
        newHtml("Test Page", "<a id=\"foo\" href=\"foo.html\">foo</a>"));
   
    AbstractDocument page = agent().get("http://test.com");
    Link link = page.links().find(byName("foo"));
    assertNull(link);
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  public void testLinkQueryByIdOrClass() {
    addPageRequest("http://test.com",
        newHtml("Test Page", "<a id=\"foo\" class=\"bar baz\" href=\"foo.html\">foo</a>"));
   
    AbstractDocument page = agent().get("http://test.com");
   
    assertNotNull(page.links().find(byIdOrClass("foo")));
    assertNotNull(page.links().find(byIdOrClass("bar")));
    assertNotNull(page.links().find(byIdOrClass("baz")));
   
    assertNull(page.links().find(byIdOrClass("x")));
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  public void testPageLinkQueryIsByIdOrClass() {
    addPageRequest("http://test.com",
        newHtml("Test Page", "<a id=\"foo\" class=\"bar baz\" href=\"foo.html\">foo</a>"));
   
    AbstractDocument page = agent().get("http://test.com");
   
    assertNotNull(page.link("foo"));
    assertNotNull(page.link("bar"));
    assertNotNull(page.link("baz"));
   
    assertNull(page.link("x"));
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  public void testFormQueryById() {
    addPageRequest("http://test.com",
        newHtml("Test Page", "<form action=\"form\" id=\"form\"></form>"));
   
    AbstractDocument page = agent().get("http://test.com");
   
    assertNull(page.form("foo"));
    assertNotNull(page.form("form"));
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testFollowingAnAbsoluteLink() {
    addPageRequest("http://test.com",
        newHtml("Test Page", "<a id=\"t\" href=\"http://test.com/myPage.html\">myPage</a>"));
    addPageRequest("http://test.com/myPage.html", newHtml("My Page", ""));
   
    AbstractDocument page = agent().get("http://test.com");
    assertEquals(1, page.links().size());
    Link link = page.links().find(byIdOrClass("t"));
    assertNotNull(link);
    Resource myPage = link.click();
    assertEquals("My Page", myPage.getTitle());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  @Test
  public void testDontFind() {
    addPageRequest("http://test.com",
        newHtml("Test Page", "<a id=\"t\" href=\"http://test.com/myPage.html\">myPage</a>"));
   
    AbstractDocument page = agent().get("http://test.com");
    assertEquals(1, page.links().size());
    Link link = page.links().find("#nothere");
    assertNull(link);
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testFollowingAnRelativeLink() {
    addPageRequest("http://test.com",
        newHtml("Test Page", "<a href=\"myPage.html\">myPage</a>"));
    addPageRequest("http://test.com/myPage.html", newHtml("My Page", ""));
   
    AbstractDocument page = agent().get("http://test.com");
    Link link = page.links().find(contains("myPage"));
    assertNotNull(link);
    Resource myPage = link.click();
    assertEquals("My Page", myPage.getTitle());
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.AbstractDocument

  public void testFollowingAnRelativeLinkWithBaseSetInHtmlPage() {
    addPageRequest("http://test.com",
        "<html><head><base href=\"http://www1.test.com\"/></head><body><a href=\"myPage.html\">myPage</a></body></html>");
    addPageRequest("http://www1.test.com/myPage.html", newHtml("My Page", ""));
   
    AbstractDocument page = agent().get("http://test.com");
    Link link = page.links().get(0);
    assertNotNull(link);
    Resource myPage = link.click();
    assertEquals("My Page", myPage.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.