Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.Page


            assertEquals(404, x.getStatusCode());
        }
    }

    public void testUnwrappedOneItem() throws Exception {
        Page page = new WebClient().goTo("api/xml?xpath=/hudson/view/name", "application/xml");
        assertEquals("<name>All</name>", page.getWebResponse().getContentAsString());
    }
View Full Code Here


        assertEquals("<name>All</name>", page.getWebResponse().getContentAsString());
    }

    public void testUnwrappedLongString() throws Exception {
        hudson.setSystemMessage("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
        Page page = new WebClient().goTo("api/xml?xpath=/hudson/description/text()", "text/plain");
        assertEquals(hudson.getSystemMessage(), page.getWebResponse().getContentAsString());
    }
View Full Code Here

  @Test
  public void checkResources() throws Exception {
    for ( String resource : EXPECTED_RESOURCES ) {
      String url = EndToEndServer.SERVER_URL + '/' + resource;
      Page p = webClient.getPage(url);
      assertEquals("Failed to load test resource " + url, 200, p.getWebResponse().getStatusCode());
    }
  }
View Full Code Here

    url += "&nocache=1";
    if (language != null) {
      url += "&lang=" + language;
    }

    Page page = webClient.getPage(url);
    if (!(page instanceof HtmlPage)) {
      fail("Got wrong page type. Was: " + page.getWebResponse().getContentType());
    }
    return (HtmlPage) page;
  }
View Full Code Here

    WebRequestSettings request = new WebRequestSettings(new URL(postURL),
        SubmitMethod.POST);  
    request.setRequestParameters(parameters);   
    log.debug(parameters.toString());
    try {
      Page page = client.getPage(request);     
      String path = page.getWebResponse().getUrl().getFile();
      return path;
    } catch (Exception e) {
      //throw new RuntimeException("Could not connect to " + postURL);
      throw new RuntimeException(e);
    }
View Full Code Here

    for (KeyValuePair current : parameters) {
      headers.put(current.getKey(), current.getValue());
    }
    request.setAdditionalHeaders(headers);
    try {
      Page page = client.getPage(request);     
      CheckoutRedirect response = (CheckoutRedirect) CartUtils.unmarshal(
          page.getWebResponse().getContentAsString()).getValue();
      URL url = new URL(URLDecoder.decode(response.getRedirectUrl(), "UTF-8"));
      String path = url.getFile();
      return path;
    } catch (Exception e) {
      throw new RuntimeException("Could not connect to " + postURL);
View Full Code Here

    private static void tryGetImage(final HtmlPage htmlPage, final String src,
                                    final WebClient webClient, final Iterator iter) {
        try {
            final URL url = htmlPage.getFullyQualifiedUrl(src);
            final Page resp = webClient.getPage(url);

            if (!(resp instanceof UnexpectedPage)) {
                LOG.info("Failed image with src=\"" + src + "\": content type is "
                        + resp.getWebResponse().getContentType());
            } else {
                // TODO: check that the content type corresponds to an image
                LOG.debug("Image with src=\"" + src + "\" is ok");
                iter.remove(); // src is ok
            }
View Full Code Here

        if (!steps.isEmpty())
        {
            for (int i = 0; i < steps.size(); i++) {
                context = processFilterStep(context, (Step) steps.get(i));
            }
            final Page currentResponse = context.getCurrentResponse();
            ContextHelper.defineAsCurrentResponse(getContext(), currentResponse.getWebResponse().getContentAsBytes(),
                    currentResponse.getWebResponse().getContentType(), "http:" + getClass().getName());
        }
    }
View Full Code Here

      verifyParameters();
      doExecute();
     
      // give time for background js tasks to finish when needed
      final Context context = getContext();
      final Page currentPage = context.getCurrentResponse();
      if (!(this instanceof IVerificationStep) && currentPage != null && context.getConfig().isEasyAjax()) {
        currentPage.getEnclosingWindow().getThreadManager().joinAll(context.getConfig().getEasyAjaxDelay());
      }
     
      final ScriptException bgException = context.getBackgroundJSError();
      if (bgException != null) {
        handleException(bgException);
View Full Code Here

        }
    }

    public void doExecute() throws Exception {
        final StringBuffer buf = new StringBuffer();
        final Page currentResponse = getContext().getCurrentResponse();
        if (currentResponse instanceof HtmlPage) {
            final HtmlPage page = (HtmlPage) currentResponse;
            processHtml(page.getDocumentElement().getChildren(), buf);
        } else if (currentResponse instanceof XmlPage) {
            final XmlPage page = (XmlPage) currentResponse;
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.Page

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.