Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.Page


  protected InputStream getResourceIfPresent(String path) throws IOException {
    InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
    InternetResource resource = builder.getResource(path);
    if (resource != null) {
      String uri = HTTP_PREFIX + resource.getUri(facesContext, null);
      Page page = webClient.getPage(uri);
      if (page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK) {
        return page.getWebResponse().getContentAsStream();
      }
    }
    throw new IOException(RESOURCE_NOT_FOUND_MESSAGE + path);
  }
View Full Code Here


          for (String script : scriptSources) {
            if (script.indexOf(javascript) >= 0) {
              foundCount++;

          String uri = HTTP_PREFIX + script;
          Page page = webClient.getPage(uri);
          if(isPageAvailabilityCheck){
            if (!(page != null && page.getWebResponse()
                .getStatusCode() == HttpServletResponse.SC_OK)) {
              throw new Exception("Component script " + javascript + " is not found in the response");
            }
          }
          break;
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());
    }
    webClient.waitForBackgroundJavaScript(3000);
    return (HtmlPage) page;
  }
View Full Code Here

        WebClient firephoque = new WebClient(browserVersion);
        firephoque.setPageCreator(new DefaultPageCreator() {

            @Override
            public Page createPage(WebResponse wr, WebWindow ww) throws IOException {
                Page page = createHtmlPage(wr, ww);
                return page;
            }
        });
        firephoque.setThrowExceptionOnFailingStatusCode(false);
        firephoque.setAlertHandler(new AlertHandler() {
            public void handleAlert(Page page, String string) {
                try {
                    Window window = (Window)page.getEnclosingWindow().getScriptObject();
                    window.custom_eval(
                        "parent.selenium.browserbot.recordedAlerts.push('" + string.replace("'", "\\'")+ "');"
                    );
                } catch(Exception e) {
                    e.printStackTrace();
                }
            }
        });
        firephoque.setConfirmHandler(new ConfirmHandler() {
            public boolean handleConfirm(Page page, String string) {
                try {
                    Window window = (Window)page.getEnclosingWindow().getScriptObject();
                    Object result = window.custom_eval(
                        "parent.selenium.browserbot.recordedConfirmations.push('" + string.replace("'", "\\'")+ "');" +
                        "var result = parent.selenium.browserbot.nextConfirmResult;" +
                        "parent.selenium.browserbot.nextConfirmResult = true;" +
                        "result"
                    );
                    return (Boolean)result;
                } catch(Exception e) {
                    e.printStackTrace();
                    return false;
                }
            }
        });
        firephoque.setPromptHandler(new PromptHandler() {
            public String handlePrompt(Page page, String string) {
                try {
                    Window window = (Window)page.getEnclosingWindow().getScriptObject();
                    Object result = window.custom_eval(
                        "parent.selenium.browserbot.recordedPrompts.push('" + string.replace("'", "\\'")+ "');" +
                        "var result = !parent.selenium.browserbot.nextConfirmResult ? null : parent.selenium.browserbot.nextPromptResult;" +
                        "parent.selenium.browserbot.nextConfirmResult = true;" +
                        "parent.selenium.browserbot.nextPromptResult = '';" +
View Full Code Here

    public static final String CID_HEADER_NAME = "org.jboss.cdi.tck.cid";

    public static final String LONG_RUNNING_HEADER_NAME = "org.jboss.cdi.tck.longRunning";

    protected boolean isCloudDestroyed(WebClient client) throws Exception {
        Page page = client.getPage(getConversationStatusPath("cloudDestroyed"));
        return page.getWebResponse().getStatusCode() == 200;
    }
View Full Code Here

        Page page = client.getPage(getConversationStatusPath("cloudDestroyed"));
        return page.getWebResponse().getStatusCode() == 200;
    }

    protected boolean isConversationContextDestroyed(WebClient client) throws Exception {
        Page page = client.getPage(getConversationStatusPath("conversationContextDestroyed"));
        return page.getWebResponse().getStatusCode() == 200;
    }
View Full Code Here

            WebClient client = new WebClient();
            client.setThrowExceptionOnFailingStatusCode(false);
            client.getCookieManager().addCookie(new Cookie(contextPath.getHost(), "JSESSIONID", jsessionid));

            Page page = client.getPage(contextPath + "introspect?mode=" + mode + "&cid=" + cid);

            if (!(page instanceof TextPage)) {
                return "" + page.getWebResponse().getStatusCode();
            }
            TextPage textPage = (TextPage) page;
            return textPage.getContent();
        }
View Full Code Here

        }

        // verify that the conversation can no longer be restored
        {
            client.setThrowExceptionOnFailingStatusCode(false);
            Page page = client.getPage(getPath("/display", cid));
            assertEquals(page.getWebResponse().getStatusCode(), 500);
        }
    }
View Full Code Here

        }

        // Verify that the conversation cannot be associated
        {
            client.setThrowExceptionOnFailingStatusCode(false);
            Page page = client.getPage(getPath("/display", cid));
            assertEquals(page.getWebResponse().getStatusCode(), 500);
        }
    }
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.