Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlPage.asXml()


  }

  @Test
  public void testTemplateLibrary() throws Exception {
    HtmlPage page = executeAllPageTests("templateLibrary");
    String pageXml = page.asXml();
    assertTrue(pageXml.replaceAll("[\n\r ]", "").contains("p{color:red}"));

    Node paragraph = page.getElementsByTagName("p").item(0);
    assertEquals("Hello world", paragraph.getTextContent().trim());
  }
View Full Code Here


        System.out.println(raw.getContent());
        String nl = System.getProperty("line.separator");
        assertTrue(raw.getContent().contains(nl+"---"+nl+"ooo"+nl+"ooo"+nl));

        // there should be two 'ooo's
        assertEquals(3,rsp.asXml().split("ooo").length);
    }

    /**
     * Only annotates the first occurrence of "ooo".
     */
 
View Full Code Here

        logger.info("Creating snapshot for page ["+page+"], escapedFragment ["+escapedFragment+"]");
        HtmlPage htmlPage = webClient.getPage(CrawlingUtils.rewriteUrl(applicationBaseURL, page, escapedFragment));
        webClient.waitForBackgroundJavaScript(javascriptTime);
        File outputFile = new File(outputDir, pagePath);
        //htmlPage.save(outputFile) creates the whole site structure, with images and CSS files locally. So use asXML instead
        StreamUtils.write(new ByteArrayInputStream(htmlPage.asXml().getBytes("UTF-8")), new FileOutputStream(outputFile), true);
        webClient.closeAllWindows();
      }
        }
        catch (Exception e)
        {
View Full Code Here

            + "You probably want to see this page: <a href=\""
            + pageName
            + "\">" + pageName + "</a></h3></center>");
        out.println("<hr />");

        out.println(page.asXml());
        webClient.closeAllWindows();

        out.println("");
        out.close();
      } catch (Throwable e) {
View Full Code Here

  }

  @Test
  public void testTemplateLibrary() throws Exception {
    HtmlPage page = executeAllPageTests("templateLibrary");
    assertTrue(page.asXml().contains("p {color: red}"));
   
    Node paragraph = page.getElementsByTagName("p").item(0);
    assertEquals("Hello world", paragraph.getTextContent().trim());
  }
 
View Full Code Here

    public void testGallery() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
        final HtmlPage page = webClient.getPage("http://localhost:8080/photark/");
        final HtmlTable table = page.getHtmlElementById("tableGallery");

        //testing the static part of the gallery
        final String pageAsXml = page.asXml();
        assertTrue(pageAsXml.contains("<a href=\"javascript:displayGallery()\" onmouseover=\"document.index.src=index_on.src\" onmouseout=\"document.index.src=index_off.src\" onmousedown=\"beforeClick();\">"));
        assertTrue(pageAsXml.contains("<body onload=\"initGallery()\">"));
        final String pageAsText = page.asText();
        assertTrue(pageAsText.contains("Apache PhotArk Gallery"));
View Full Code Here

    public void testGallery() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
        final HtmlPage page = webClient.getPage("http://localhost:8080/photark/");
        final HtmlTable table = page.getHtmlElementById("tableGallery");

        //testing the static part of the gallery
        final String pageAsXml = page.asXml();
        assertTrue(pageAsXml.contains("<a href=\"javascript:displayGallery()\" onmouseover=\"document.index.src=index_on.src\" onmouseout=\"document.index.src=index_off.src\" onmousedown=\"beforeClick();\">"));
        assertTrue(pageAsXml.contains("<body onload=\"initGallery()\">"));
        final String pageAsText = page.asText();
        assertTrue(pageAsText.contains("Apache PhotArk Gallery"));
View Full Code Here

    public void testGallery() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
        final HtmlPage page = webClient.getPage("http://localhost:8080/photark/");
        final HtmlTable table = page.getHtmlElementById("tableGallery");

        //testing the static part of the gallery
        final String pageAsXml = page.asXml();
        assertTrue(pageAsXml.contains("<a href=\"javascript:displayGallery()\" onmouseover=\"document.index.src=index_on.src\" onmouseout=\"document.index.src=index_off.src\" onmousedown=\"beforeClick();\">"));
        assertTrue(pageAsXml.contains("<body onload=\"initGallery()\">"));
        final String pageAsText = page.asText();
        assertTrue(pageAsText.contains("Apache PhotArk Gallery"));
View Full Code Here

        stringBuilder.append("<center><h3>You are viewing a non-interactive page that is intended for the crawler.  ");
        stringBuilder.append("You probably want to see this page: <a href=\"" + url + "\">" + url +
                "</a></h3></center>\n");
        stringBuilder.append("<hr />\n");

        stringBuilder.append(page.asXml());
        webClient.closeAllWindows();
        return stringBuilder;
    }

    /**
 
View Full Code Here

    else if (domChangedInLastPage && fContext.getCurrentResponse() instanceof HtmlPage)
    {
      final HtmlPage page = (HtmlPage) fContext.getCurrentResponse();
      resp = page.getWebResponse();
      file = getResponseFile("html", savePrefix, fCurrentResult.getTaskName());
      writeStringToFile(file, page.asXml());
    }
    else
    {
      // nothing to dump
      return;
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.