Examples of MechanizeAgent


Examples of com.gistlabs.mechanize.MechanizeAgent

            SchemeRegistry schemeRegistry = new SchemeRegistry();
            schemeRegistry.register(httpsScheme);

            DefaultHttpClient httpClient = new DefaultHttpClient(new PoolingClientConnectionManager(schemeRegistry));

            MechanizeAgent agent = new MechanizeAgent();
            Cookie cookie2 = agent.cookies().addNewCookie("gpw_e24", ".", "oracle.com");
            cookie2.getHttpCookie().setPath("/");
            cookie2.getHttpCookie().setSecure(false);


View Full Code Here

Examples of com.gistlabs.mechanize.impl.MechanizeAgent

*/
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

Examples of com.gistlabs.mechanize.impl.MechanizeAgent

    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

Examples of com.gistlabs.mechanize.impl.MechanizeAgent

*/
public class MechanizeAgentIntTest extends MechanizeTestCase {
  static final String firefoxUserAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.1) Gecko/20100122 firefox/3.6.1";

  protected Mechanize agent() {
    return new MechanizeAgent().setUserAgent(firefoxUserAgent);
  }
View Full Code Here

Examples of com.gistlabs.mechanize.impl.MechanizeAgent

  //@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

Examples of com.gistlabs.mechanize.impl.MechanizeAgent

*/
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

Examples of com.gistlabs.mechanize.impl.MechanizeAgent

    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

Examples of com.gistlabs.mechanize.impl.MechanizeAgent

    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

Examples of com.gistlabs.mechanize.impl.MechanizeAgent

* @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

Examples of com.gistlabs.mechanize.impl.MechanizeAgent


  /** Tests if google stores two cookies. It uses a special link to prevent google form choosing a different homepage depending on the ip being used. */
  @Test
  public void testGoogleComSendsTwoCookies() {
    MechanizeAgent agent = new MechanizeAgent();

    agent.
    doRequest("https://www.google.co.uk/setprefdomain?prefdom=US&sig=0_iEtQ0487gjqkcvDjBk5XCH1G_WU%3D").
    addHeader("Accept-Language", "en-US").
    get();
    assertEquals(2, agent.cookies().getCount());
    assertNotNull(agent.cookies().get("NID", ".google.co.uk"));
    assertNotNull(agent.cookies().get("PREF", ".google.co.uk"));
  }
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.