Package com.gistlabs.mechanize.document.link

Examples of com.gistlabs.mechanize.document.link.Link


  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


   
    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

  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

        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

    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

    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

    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

        newHtml("Test Page", "<a href=\"myPage.html\">myPage</a>"));
    pageRequest.setContentLocation("http://www1.test.com");
    addPageRequest("http://www1.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

    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']");
    assertNotNull(link);
    Resource englishPage = link.click();
    assertEquals("Wikipedia, the free encyclopedia", englishPage.getTitle());
  }
View Full Code Here

TOP

Related Classes of com.gistlabs.mechanize.document.link.Link

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.