Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.Page


    WebWindow findTopLevelWindowByTitle(final WebClient webClient) {
        for (final Iterator iter = webClient.getWebWindows().iterator(); iter.hasNext();) {
            final WebWindow window = (WebWindow) iter.next();
            if (window instanceof TopLevelWindow)
             {
              final Page containedPage = window.getEnclosedPage();
              if (containedPage instanceof HtmlPage
                  && getTitle().equals(((HtmlPage) containedPage).getTitleText())) {
                return window;
              }
            }
View Full Code Here


      final StringBuffer sb = new StringBuffer();
        int i = 0;
        for (Iterator iter = webClient.getWebWindows().iterator(); iter.hasNext();) {
            final WebWindow curWindow = (WebWindow) iter.next();
            if (curWindow instanceof TopLevelWindow) {
              final Page page = curWindow.getEnclosedPage();
              if (i > 0)
                sb.append("\n");
              sb.append("index: " + i + ", name: >" + curWindow.getName() + "<");
              if (page instanceof HtmlPage) {
                sb.append(", title: >" + ((HtmlPage) page).getTitleText() + "<");
              }
              else {
                sb.append(", " + page.getWebResponse().getContentType());
              }
              sb.append(", url: " + page.getWebResponse().getRequestUrl());
              ++i;
            }
        }
        return sb.toString();
    }
View Full Code Here

  protected boolean isComparingPathAndValue() {
    return getText() != null;
  }

  protected void verifyXPath() throws XPathException, StepFailedException {
    final Page currentResponse = getContext().getCurrentResponse();
    final XPathHelper xpathHelper = getContext().getXPathHelper();

    if (isComparingPathAndValue()) {
      final String actualValue = xpathHelper.stringValueOf(currentResponse, getXpath());
      if (!verifyText(actualValue)) {
View Full Code Here

public class ContentStripperFilter extends AbstractFilter
{
    private static final Logger LOG = Logger.getLogger(ContentStripperFilter.class);

  public void doExecute() throws Exception {
        final Page currentResponse = getContext().getCurrentResponse();
        final String origType = currentResponse.getWebResponse().getContentType();
        LOG.info("Filtering response of type " + origType);

        final StringBuffer buf = new StringBuffer();
        if (currentResponse instanceof HtmlPage)
        {
View Full Code Here

  }

    void processLink(final HtmlAnchor link, final int depth) throws IOException {
        try {
            follow(link);
            final Page page = fContext.getCurrentResponse();
            if (page instanceof HtmlPage)
            {
              visit((HtmlPage) page, depth - 1);
            }
            else
            {
              final WebResponse response = page.getWebResponse();
              LOG.info("Don't going deeper in response for " + response.getRequestUrl()
                  + " as it isn't an html page (content type: "
                  + response.getContentType() + ", page" + page + ")");
            }
        }
View Full Code Here

    final String src = (String) linkAttribute.getValue();

    final URL url = htmlPage.getFullyQualifiedUrl(src);
    LOG.debug(src + " -> " + url.toExternalForm());
    try {
      final Page resp = webClient.getPage(url);
      final String contentType = resp.getWebResponse().getContentType();

      if (!fMimeTypes.match(contentType)) {
        final StringBuffer sb = new StringBuffer();
        sb.append(src).append(" <").append(url.toExternalForm()).append("> ");
        sb.append(contentType).append(" is not expected").append(LINE_SEPARATOR);
View Full Code Here

  public void doExecute() throws XPathException {
    storeProperty(evaluateXPath());
  }

  protected String evaluateXPath() throws XPathException {
    final Page currentResponse = getContext().getCurrentResponse();
    final XPathHelper xpathHelper = getContext().getXPathHelper();
    final String result = xpathHelper.stringValueOf(currentResponse, getXpath());

    // seems that result is "" and not null when nothing is found
    if (result == null
View Full Code Here

public class NormalizeXmlFilter extends AbstractFilter
{
    private static final Logger LOG = Logger.getLogger(NormalizeXmlFilter.class);

    public void doExecute() throws Exception {
        final Page currentResponse = getContext().getCurrentResponse();
        if (currentResponse instanceof XmlPage) {
            processXml((XmlPage) currentResponse);
        } else {
            LOG.warn("Ignoring non-XML response");
        }
View Full Code Here

    protected static final int ANY_PAGE = -1;

    protected PDFPage getPdfPage()
    {
        nullResponseCheck();
      final Page page = getContext().getCurrentResponse();
      if (page instanceof PDFPage)
        return (PDFPage) page;
     
      throw new StepExecutionException("Current response is not a PDF page but has following mime type "
          + page.getWebResponse().getContentType() + " (" + page + ")", this);
    }
View Full Code Here

    /**
     * @throws StepExecutionException
     *          if pdf analyzer cannot be initialized correctly
     */
    protected HSSFWorkbook getExcelWorkbook() {
      final Page currentPage = getContext().getCurrentResponse();
      HSSFWorkbook workbook = (HSSFWorkbook) sMapWorkbooks.get(currentPage);
      if (workbook == null) {
        workbook = createWorkbook(currentPage);
        sMapWorkbooks.put(currentPage, workbook); // weak map, analyser garbage collected together with the page
      }
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.