Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.Page


    {
      HtmlForm form = (HtmlForm)iter.next();
      // Get the "name" form input field
      HtmlInput login = form.getInputByName("name");
      System.err.println(login.getValueAttribute());
      Page resultPage = form.submit();
      // Check response from servlet
      WebResponse resultResponse  = resultPage.getWebResponse();
      assertTrue(resultResponse.getStatusCode() <= 200);
     
      // TODO Check response content..
      String response = resultResponse.getContentAsString();
     
View Full Code Here


import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.SgmlPage;

public class CustomHtmlUnitDriver extends HtmlUnitDriver {
  public String getPageSourceAsText() {
    Page page = lastPage();
    if (page == null) {
      return null;
    }

    if (page instanceof SgmlPage) {
View Full Code Here

      webClient.setThrowExceptionOnFailingStatusCode(false);
      webClient.setThrowExceptionOnScriptError(true);
      webClient.setOnbeforeunloadHandler(this);
      setupWebClient(webClient);
      try {
        Page page = webClient.getPage(url);
        webClient.waitForBackgroundJavaScriptStartingBefore(2000);
        treeLogger.log(TreeLogger.SPAM, "getPage returned "
            + ((HtmlPage) page).asXml());
        // TODO(amitmanjhi): call webClient.closeAllWindows()
      } catch (FailingHttpStatusCodeException e) {
View Full Code Here

        for( Element jar : (List<Element>)dom.selectNodes("//jar") ) {
            URL url = new URL(baseUrl,jar.attributeValue("href"));
            System.out.println(url);
           
            // now make sure that these URLs are unprotected
            Page jarResource = jnlpAgent.getPage(url);
            assertTrue(jarResource.getWebResponse().getContentType().toLowerCase(Locale.ENGLISH).startsWith("application/"));
        }
    }
View Full Code Here

    protected HtmlPage evaluateAsHtml(String jellyScript) throws Exception {
        HudsonTestCase.WebClient wc = new WebClient();
       
        WebRequestSettings req = new WebRequestSettings(wc.createCrumbedUrl("eval"), POST);
        req.setRequestBody("<j:jelly xmlns:j='jelly:core' xmlns:st='jelly:stapler' xmlns:l='/lib/layout' xmlns:f='/lib/form'>"+jellyScript+"</j:jelly>");
        Page page = wc.getPage(req);
        return (HtmlPage) page;
    }
View Full Code Here

    public void testSearchByProjectName() throws Exception {
        final String projectName = "testSearchByProjectName";
       
        createFreeStyleProject(projectName);
       
        Page result = search(projectName);
        Assert.assertNotNull(result);
        assertGoodStatus(result);
       
        // make sure we've fetched the testSearchByDisplayName project page
        String contents = result.getWebResponse().getContentAsString();
        Assert.assertTrue(contents.contains(String.format("<title>%s [Jenkins]</title>", projectName)));
    }
View Full Code Here

        final String displayName = "displayName9999999";
       
        FreeStyleProject project = createFreeStyleProject("testSearchByDisplayName");
        project.setDisplayName(displayName);
       
        Page result = search(displayName);
        Assert.assertNotNull(result);
        assertGoodStatus(result);
       
        // make sure we've fetched the testSearchByDisplayName project page
        String contents = result.getWebResponse().getContentAsString();
        Assert.assertTrue(contents.contains(String.format("<title>%s [Jenkins]</title>", displayName)));
    }
View Full Code Here

        project3.setDisplayName(otherDisplayName);

        // make sure that on search we get back one of the projects, it doesn't
        // matter which one as long as the one that is returned has displayName
        // as the display name
        Page result = search(displayName);
        Assert.assertNotNull(result);
        assertGoodStatus(result);

        // make sure we've fetched the testSearchByDisplayName project page
        String contents = result.getWebResponse().getContentAsString();
        Assert.assertTrue(contents.contains(String.format("<title>%s [Jenkins]</title>", displayName)));
        Assert.assertFalse(contents.contains(otherDisplayName));
    }
View Full Code Here

        // create a third project and make sure it's not picked up by search
        FreeStyleProject project3 = createFreeStyleProject(project3Name);
        project3.setDisplayName(project3DisplayName);
       
        // search for foo
        Page result = search(project1Name);
        Assert.assertNotNull(result);
        assertGoodStatus(result);
       
        // make sure we get the project with the name foo
        String contents = result.getWebResponse().getContentAsString();
        Assert.assertTrue(contents.contains(String.format("<title>%s [Jenkins]</title>", project1DisplayName)));
        // make sure projects 2 and 3 were not picked up
        Assert.assertFalse(contents.contains(project2Name));
        Assert.assertFalse(contents.contains(project3Name));
        Assert.assertFalse(contents.contains(project3DisplayName));
View Full Code Here

        FreeStyleProject project1 = createFreeStyleProject(projectName);
        project1.setDisplayName(displayName);
       
        WebClient wc = new WebClient();
        Page result = wc.goTo("search/suggest?query=name", "application/javascript");
        Assert.assertNotNull(result);
        assertGoodStatus(result);
       
        String content = result.getWebResponse().getContentAsString();
        System.out.println(content);
        JSONObject jsonContent = (JSONObject)JSONSerializer.toJSON(content);
        Assert.assertNotNull(jsonContent);
        JSONArray jsonArray = jsonContent.getJSONArray("suggestions");
        Assert.assertNotNull(jsonArray);
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.