Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlPage


  
   @Test(dependsOnMethods={"homePageLoadTest"})
   public void fileUploadTest() throws IOException {
      final HtmlAnchor linkEl = (HtmlAnchor) page.getFirstByXPath(FILE_UPLOAD_LINK);
     
      final HtmlPage uploadPage = (HtmlPage) linkEl.click();
      if (uploadPage == null){
         fail("Could not read page");
      }
           
      final HtmlInput el1 = (HtmlInput) uploadPage.getFirstByXPath(FILE_UPLOAD_FILE);
      if (el1 == null) {
         fail("Element file upload file doesn't exist");
      } else {        
         el1.type(IMAGE_TO_UPLOAD);
      }     
     
      final HtmlInput el2 = (HtmlInput) uploadPage.getFirstByXPath(FILE_UPLOAD_UPDATE);
      final HtmlPage finishPage = (HtmlPage) el2.click();
      final HtmlElement el3 = (HtmlElement) finishPage.getFirstByXPath(FILE_UPLOAD_RESPONSE);
     
      assertFalse("Page should contain \"Successfully updated\"", el3 == null);
   }
View Full Code Here


  
   @Test(dependsOnMethods={"homePageLoadTest","fileUploadTest"})
   public void graphicImageTest() throws IOException {
      final HtmlAnchor linkEl = (HtmlAnchor) page.getFirstByXPath(GRAPHIC_IMAGE_LINK);
     
      final HtmlPage graphicPage = (HtmlPage) linkEl.click();
      if (graphicPage == null){
         fail("Could not read page");
      }
     
      final HtmlImage image = (HtmlImage) graphicPage.getFirstByXPath(IMAGE);
     
      assertFalse("Page should contain image of Pete Muir", image == null);     
   }     
View Full Code Here

        ((DefaultCredentialsProvider) webClient.getCredentialsProvider()).addCredentials("admin", "admin");
    }

    @Test
    public void testWebConsolePlugin() throws IOException {
        final HtmlPage page = webClient.getPage(prepareUrl(PLUGIN_SUFFIX));
        String text = page.asText();

        //Filter name should be part of Filter table
        assertTrue(text.contains("WebConsoleTestTurboFilter"));

        //Console name should be part of console table
View Full Code Here

        assertTrue(text.contains("testremote.log"));
    }

    @Test
    public void testPrinter() throws IOException {
        final HtmlPage page = webClient.getPage(prepareUrl(PRINTER_SUFFIX));
        String text = page.asText();

        //Should dump content of configured file testremote.log
        //with its name
        assertTrue(text.contains("testremote.log"));
    }
View Full Code Here

    @Rule
    public JenkinsRule j = new JenkinsRule();

    @Test
    public void testGlobalConfigDefaultState() throws Exception {
        HtmlPage page = j.createWebClient().goTo("configure");

        assertEquals("Should be at the Configure System page",
                "Configure System [Jenkins]", page.getTitleText());

        // override global settings checkbox control               
        HtmlCheckBoxInput overrideGlobal = page.getElementByName("ext_mailer_override_global_settings");
        assertNotNull("Override global settings should be present", overrideGlobal);
        assertFalse("Override global config should not be checked by default", overrideGlobal.isChecked());

        // default content type select control
        HtmlSelect contentType = page.getElementByName("ext_mailer_default_content_type");
        assertNotNull("Content type selection should be present", contentType);
        assertEquals("Plain text should be selected by default",
                "text/plain", contentType.getSelectedOptions().get(0).getValueAttribute());

        HtmlCheckBoxInput useListId = page.getElementByName("ext_mailer_use_list_id");
        assertNotNull("Use List ID should be present", useListId);
        assertFalse("Use List ID should not be checked by default", useListId.isChecked());

        HtmlCheckBoxInput precedenceBulk = page.getElementByName("ext_mailer_add_precedence_bulk");
        assertNotNull("Precedence Bulk should be present", precedenceBulk);
        assertFalse("Add precedence bulk should not be checked by default",
                precedenceBulk.isChecked());

        HtmlTextInput defaultRecipients = page.getElementByName("ext_mailer_default_recipients");
        assertNotNull("Default Recipients should be present", defaultRecipients);
        assertEquals("Default recipients should be blank by default",
                "", defaultRecipients.getText());

        HtmlTextInput defaultReplyTo = page.getElementByName("ext_mailer_default_replyto");
        assertNotNull("Default Reply-to should be present", defaultReplyTo);
        assertEquals("Default Reply-To should be blank by default",
                "", defaultReplyTo.getText());

        HtmlTextInput emergencyReroute = page.getElementByName("ext_mailer_emergency_reroute");
        assertNotNull("Emergency Reroute should be present", emergencyReroute);
        assertEquals("Emergency Reroute should be blank by default",
                "", emergencyReroute.getText());
       
        HtmlTextInput excludedRecipients = page.getElementByName("ext_mailer_excluded_committers");
        assertNotNull("Excluded Recipients should be present", excludedRecipients);
        assertEquals("Excluded Recipients should be blank by default",
                "", excludedRecipients.getText());

        HtmlTextInput defaultSubject = page.getElementByName("ext_mailer_default_subject");
        assertNotNull("Default Subject should be present", defaultSubject);
        assertEquals("Default Subject should be set",
                "$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!",
                defaultSubject.getText());
       
        HtmlTextInput maxAttachmentSize = page.getElementByName("ext_mailer_max_attachment_size");
        assertNotNull("Max attachment size should be present", maxAttachmentSize);
        assertEquals("Max attachment size should be blank by default",
                "", maxAttachmentSize.getText());
       
        HtmlTextArea defaultContent = page.getElementByName("ext_mailer_default_body");
        assertNotNull("Default content should be present", defaultContent);
        assertEquals("Default content should be set by default",
                "$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:\n\nCheck console output at $BUILD_URL to view the results.",
                defaultContent.getText());
       
        HtmlCheckBoxInput debugMode = page.getElementByName("ext_mailer_debug_mode");
        assertNotNull("Debug mode should be present", debugMode);
        assertFalse("Debug mode should not be checked by default", debugMode.isChecked());
       
        HtmlCheckBoxInput securityMode = page.getElementByName("ext_mailer_security_enabled");
        assertNotNull("Security mode should be present", securityMode);
        assertFalse("Security mode should not be checked by default", securityMode.isChecked());
       
        try {
            page.getElementByName("defaultClasspath");
            fail("defaultClasspath section should not be present");
        } catch (ElementNotFoundException e) {}
    }
View Full Code Here

   
    @Test
    @Bug(20030)
    public void testGlobalConfigSimpleRoundTrip() throws Exception {
        ExtendedEmailPublisherDescriptor descriptor = j.jenkins.getDescriptorByType(ExtendedEmailPublisherDescriptor.class);       
        HtmlPage page = j.createWebClient().goTo("configure");
        HtmlTextInput defaultRecipients = page.getElementByName("ext_mailer_default_recipients");
        defaultRecipients.setValueAttribute("mickey@disney.com");
        j.submit(page.getFormByName("config"));      
       
        assertEquals("mickey@disney.com", descriptor.getDefaultRecipients());
    }
View Full Code Here

    @Test
    @Bug(20133)
    public void testPrecedenceBulkSettingRoundTrip() throws Exception {
        ExtendedEmailPublisherDescriptor descriptor = j.jenkins.getDescriptorByType(ExtendedEmailPublisherDescriptor.class);
        HtmlPage page = j.createWebClient().goTo("configure");
        HtmlCheckBoxInput addPrecedenceBulk = page.getElementByName("ext_mailer_add_precedence_bulk");
        addPrecedenceBulk.setChecked(true);
        j.submit(page.getFormByName("config"));

        assertEquals(true, descriptor.getPrecedenceBulk());
    }
View Full Code Here

    @Test
    @Bug(20133)
    public void testListIDRoundTrip() throws Exception {
        ExtendedEmailPublisherDescriptor descriptor = j.jenkins.getDescriptorByType(ExtendedEmailPublisherDescriptor.class);
        HtmlPage page = j.createWebClient().goTo("configure");
        HtmlCheckBoxInput useListId = page.getElementByName("ext_mailer_use_list_id");
        useListId.setChecked(true);
        HtmlTextInput listId = page.getElementByName("ext_mailer_list_id");
        listId.setValueAttribute("hammer");

        j.submit(page.getFormByName("config"));

        assertEquals("hammer", descriptor.getListId());
    }
View Full Code Here

       
        public void run() {
           
            try {
               
                HtmlPage page = (HtmlPage) client.getPage(
                        "http://localhost:8989/mvc/serv/jsp/basic/client" + clientNum);
                DomNodeList<HtmlElement> elements = page.getElementsByTagName("h1");
                checkEquals(1, elements.size());
                HtmlElement h1 = elements.get(0);
                checkEquals("client" + clientNum, h1.getTextContent());
               
            } catch (Exception e) {
View Full Code Here

            super(baseURL);
        }

        public void run() {
            try {
                HtmlPage page = (HtmlPage) client.getPage(baseURL + "/index/with-param?var=hello");
                DomNodeList<HtmlElement> elements = page.getElementsByTagName("h2");
                checkEquals(1, elements.size());
                HtmlElement h2 = elements.get(0);
                checkEquals("index/with-param hello", h2.getTextContent());
            } catch (Exception e) {
                logger.error("error", e);
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.html.HtmlPage

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.