Examples of ViewPage


Examples of org.xwiki.test.ui.framework.elements.ViewPage

        // TODO: this should be a PageObject API
        Assert.assertEquals(0, getUtil().findElementsWithoutWaiting(getDriver(),
            By.id("annotationsdisplay")).size());
        annotationsWindow.simulateCTRL_M();

        ViewPage vp = new ViewPage();
        // TODO: this should be a PageObject API
        vp.waitUntilElementIsVisible(By.className("xnotification-warning"));
        // TODO: this should be a PageObject API
        WebElement warning = getDriver().findElement(By.className("xnotification-warning"));
        Assert.assertEquals(XWIKI_SYNTAX_1_WARNING, warning.getText());

        adminPage.gotoPage();
        annotationsAdminPage = adminPage.clickAnnotationsSection();
        annotationsAdminPage.activateAnnotations();
        annotationsAdminPage.displayAnnotationsByDefault();
        annotationsAdminPage.displayAnnotationsHighlightByDefault();
        annotationsAdminPage.clickSave();

        getUtil().gotoPage(SPACE_NAME, DOC_NAME);
        // Landing directly on this page might result in notification not to be displayed
        getDriver().navigate().refresh();
        // TODO: this should be a PageObject API
        vp.waitUntilElementIsVisible(By.id("body"));

        vp = new ViewPage();
        // TODO: this should be a PageObject API
        vp.waitUntilElementIsVisible(By.className("xnotification-warning"));
        // TODO: this should be a PageObject API
        warning = getDriver().findElement(By.className("xnotification-warning"));
        Assert.assertEquals(XWIKI_SYNTAX_1_WARNING, warning.getText());
    }
View Full Code Here

Examples of org.xwiki.test.ui.framework.elements.ViewPage

    private TestUtils util = new TestUtils();

    @Test
    public void testKeyboardShortcuts()
    {
        ViewPage vp = util.gotoPage("Sandbox", "WebHome");

        // Test default edit mode (WYSIWYG for sandbox webhome) key
        vp.sendKeys("e");
        vp.waitUntilPageIsLoaded();
        Assert.assertTrue(util.isInWYSIWYGEditMode());

        // Test Cancel key
        vp.sendKeys(Keys.ALT, "c");
        vp.waitUntilPageIsLoaded();
        Assert.assertTrue(util.isInViewMode());

        // Test Wiki edit key
        vp.sendKeys("k");
        vp.waitUntilPageIsLoaded();
        Assert.assertTrue(util.isInWikiEditMode());

        // Test WYSIWYG edit mode key
        vp = this.util.gotoPage("Sandbox", "WebHome");
        vp.sendKeys("e");
        vp.waitUntilPageIsLoaded();
        Assert.assertTrue(util.isInWYSIWYGEditMode());

        // Test Inline edit mode key
        vp = this.util.gotoPage("Sandbox", "WebHome");
        vp.sendKeys("f");
        vp.waitUntilPageIsLoaded();
        Assert.assertTrue(util.isInInlineEditMode());

        // Test Rights edit mode key
        vp = this.util.gotoPage("Sandbox", "WebHome");
        vp.sendKeys("r");
        vp.waitUntilPageIsLoaded();
        Assert.assertTrue(util.isInRightsEditMode());

        // Test Object edit mode key
        vp = this.util.gotoPage("Sandbox", "WebHome");
        vp.sendKeys("o");
        vp.waitUntilPageIsLoaded();
        Assert.assertTrue(util.isInObjectEditMode());

        // Test Class edit mode key
        vp = this.util.gotoPage("Sandbox", "WebHome");
        vp.sendKeys("s");
        vp.waitUntilPageIsLoaded();
        Assert.assertTrue(util.isInClassEditMode());

        // Test Delete key
        vp = this.util.gotoPage("Sandbox", "WebHome");
        vp.sendKeys(Keys.DELETE);
        Assert.assertTrue(util.isInDeleteMode());

        // Test Rename key
        vp = this.util.gotoPage("Sandbox", "WebHome");
        vp.sendKeys(Keys.F2);
        Assert.assertTrue(util.isInRenameMode());
    }
View Full Code Here

Examples of org.xwiki.test.ui.framework.elements.ViewPage

    {
        getUtil().deletePage("Test", "BacklinkTargetTest");
        getUtil().deletePage("Test", "BacklinkSourceTest");

        // Create page listing backlinks leading to it.
        ViewPage vp = getUtil().createPage("Test", "BacklinkTargetTest", backlinkListCode, null, syntaxId);
        // No backlinks at this stage
        Assert.assertEquals("", vp.getContent());

        // Create page pointing to the page listing the backlinks.
        getUtil().createPage("Test", "BacklinkSourceTest", backlinkLink, null, syntaxId);

        vp = getUtil().gotoPage("Test", "BacklinkTargetTest");
        Assert.assertEquals("Test.BacklinkSourceTest", vp.getContent());
    }
View Full Code Here

Examples of org.xwiki.test.ui.framework.elements.ViewPage

        String templateContent = "My Template Content";
        String templateTitle = "My Template Title";
        String templateProviderName = TEMPLATE_NAME + "Provider";
        String templateProviderFullName = getTestClassName() + "." + templateProviderName;

        ViewPage templateProviderView = createTemplate(templateProviderName, templateContent, templateTitle, false);

        // Create the new document from template
        CreatePagePage createPagePage = templateProviderView.createPage();
        // Save the number of available templates so that we can make some checks later on.
        int availableTemplateSize = createPagePage.getAvailableTemplateSize();
        String templateInstanceName = TEMPLATE_NAME + "Instance";
        WYSIWYGEditPage templateInstanceEditWysiwyg =
            createPagePage.createPageFromTemplate(getTestClassName(), templateInstanceName, templateProviderFullName);
        WikiEditPage templateInstanceEdit = templateInstanceEditWysiwyg.clickSaveAndView().editWiki();

        // Verify template instance content
        Assert.assertEquals(templateInstanceName, templateInstanceEdit.getTitle());
        Assert.assertEquals(templateContent, templateInstanceEdit.getContent());
        // check the parent of the template instance
        Assert.assertEquals(templateProviderFullName, templateInstanceEdit.getParent());

        // Put a wanted link in the template instance
        templateInstanceEdit.setContent("[[NewPage]]");
        ViewPage vp = templateInstanceEdit.clickSaveAndView();

        // Verify that clicking on the wanted link pops up a box to choose the template.
        vp.clickWantedLink(getTestClassName(), "NewPage", true);
        List<WebElement> templates = getDriver().findElements(By.name("templateprovider"));
        // Note: We need to remove 1 to exclude the "Empty Page" template entry
        Assert.assertEquals(availableTemplateSize, templates.size() - 1);
        Assert.assertTrue(createPagePage.getAvailableTemplates().contains(templateProviderFullName));

        // Create a new page from template by going to a non-existing page
        // And make sure we're on a non-existing page
        Assert.assertFalse(getUtil().gotoPage(getTestClassName(), TEMPLATE_NAME + "UnexistingInstance").exists());
        DocumentDoesNotExistPage unexistingPage = new DocumentDoesNotExistPage();
        unexistingPage.clickEditThisPageToCreate();
        // make sure we're in create mode
        Assert.assertTrue(getUtil().isInCreateMode());
        CreatePagePage createUnexistingPage = new CreatePagePage();
        // count the available templates, make sure they're as many as before and that our template is among them
        templates = getDriver().findElements(By.name("templateprovider"));
        // Note: We need to remove 1 to exclude the "Empty Page" template entry
        Assert.assertEquals(availableTemplateSize, templates.size() - 1);
        Assert.assertTrue(createPagePage.getAvailableTemplates().contains(templateProviderFullName));
        // select it
        createUnexistingPage.setTemplate(templateProviderFullName);
        // and create
        createUnexistingPage.clickCreate();
        WYSIWYGEditPage unexistingPageEditWysiwyg = new WYSIWYGEditPage();
        WikiEditPage unexistingPageEdit = unexistingPageEditWysiwyg.clickSaveAndView().editWiki();

        // Verify template instance content
        Assert.assertEquals(TEMPLATE_NAME + "UnexistingInstance", unexistingPageEdit.getTitle());
        Assert.assertEquals(templateContent, unexistingPageEdit.getContent());
        // test that this page has no parent
        Assert.assertEquals("", unexistingPageEdit.getParent());

        // create an empty page when there is a template available, make sure it's empty
        CreatePagePage createEmptyPage = new CreatePagePage();
        createEmptyPage.gotoPage();
        Assert.assertTrue(createEmptyPage.getAvailableTemplateSize() > 0);
        WYSIWYGEditPage editEmptyPage = createEmptyPage.createPage(getTestClassName(), "EmptyPage");
        Assert.assertTrue(getUtil().isInWYSIWYGEditMode());
        // wait to load editor to make sure that what we're saving is the content that is supposed to be in this
        // document
        editEmptyPage.getContentEditor().waitToLoad();
        ViewPage emptyPage = editEmptyPage.clickSaveAndView();
        // make sure it's empty
        Assert.assertEquals("", emptyPage.getContent());
        // make sure parent is the right one
        Assert.assertTrue(emptyPage.hasBreadcrumbContent("Wiki Home", false));
        // mare sure title is the right one
        Assert.assertEquals("EmptyPage", emptyPage.getDocumentTitle());

        // Restrict the template to its own space
        templateProviderView = getUtil().gotoPage(getTestClassName(), TEMPLATE_NAME + "Provider");
        templateProviderView.editInline();
        TemplateProviderInlinePage templateProviderInline = new TemplateProviderInlinePage();
View Full Code Here

Examples of org.xwiki.test.ui.framework.elements.ViewPage

        spacesToExclude.add(space);
        List<WebElement> existingTemplatesLinks = sectionPage.getExistingTemplatesLinks();
        for (int i = 0; i < existingTemplatesLinks.size(); i++) {
            WebElement link = existingTemplatesLinks.get(i);
            link.click();
            ViewPage templateViewPage = new ViewPage();
            templateViewPage.editInline();
            TemplateProviderInlinePage providerEditPage = new TemplateProviderInlinePage();
            providerEditPage.excludeSpaces(spacesToExclude);
            providerEditPage.clickSaveAndView();

            // go back to the admin page, to leave this in a valid state
            sectionPage.gotoPage();
            existingTemplatesLinks = sectionPage.getExistingTemplatesLinks();
        }

        // TODO: should reset these template settings at the end of the test, to leave things in the same state as they
        // were at the beginning of the test

        // and now start testing!

        // 1/ create a page from the link in the page displayed when navigating to a non-existing page
        Assert.assertFalse(getUtil().gotoPage(space, "NewUnexistingPage").exists());
        DocumentDoesNotExistPage nonExistingPage = new DocumentDoesNotExistPage();
        nonExistingPage.clickEditThisPageToCreate();
        // make sure we're not in create mode anymore
        Assert.assertFalse(getUtil().isInCreateMode());
        // make sure we're directly in edit mode
        Assert.assertTrue(getUtil().isInWYSIWYGEditMode());
        // TODO: check that we're indeed in the edit mode of space.NewUnexitingPage
        WYSIWYGEditPage editNewUnexistingPage = new WYSIWYGEditPage();
        Assert.assertEquals(space, editNewUnexistingPage.getMetaDataValue("space"));
        Assert.assertEquals("NewUnexistingPage", editNewUnexistingPage.getMetaDataValue("page"));

        // 2/ create a page from the create menu on an existing page, by filling in space and name
        ViewPage spaceHomePage = getUtil().gotoPage(space, "WebHome");
        CreatePagePage createNewPage = spaceHomePage.createPage();
        // we expect no templates available
        Assert.assertEquals(0, createNewPage.getAvailableTemplateSize());
        // fill in data and create the page
        createNewPage.setSpace(space);
        createNewPage.setPage("NewPage");
        createNewPage.clickCreate();
        // we expect to go to the edit mode of the new page
        Assert.assertFalse(getUtil().isInCreateMode());
        Assert.assertTrue(getUtil().isInWYSIWYGEditMode());
        WYSIWYGEditPage editNewPage = new WYSIWYGEditPage();
        Assert.assertEquals(space, editNewPage.getMetaDataValue("space"));
        Assert.assertEquals("NewPage", editNewPage.getMetaDataValue("page"));

        // 3/ create a page from a link in another page
        // we're in edit mode of the newly created page from template
        WYSIWYGEditPage editNewPageWysiwyg = new WYSIWYGEditPage();
        // sometimes this fails to find the edit button, for a reason for which I don't understand...
        WikiEditPage editNewPageWiki = editNewPageWysiwyg.clickSaveAndView().editWiki();
        // put a link to the new page to create
        editNewPageWiki.setContent("[[NewLinkedPage]]");
        ViewPage newPage = editNewPageWiki.clickSaveAndView();
        // no templates are available, so we don't expect a panel with a list of templates, we just expect it goes
        // directly to edit mode of the new page
        // it would be nice to be able to test here that the create page panel is not displayed, ever. However, we can't
        // since we need to wait for that time, and we don't know how much is never.
        newPage.clickWantedLink(space, "NewLinkedPage", false);
        WYSIWYGEditPage editNewLinkedPage = new WYSIWYGEditPage();
        // since the edit mode loads as a result of a redirect that comes from a async call made by the click, we need
        // to wait for the page to load
        editNewLinkedPage.waitUntilElementIsVisible(By
            .xpath("//div[@id='tmCurrentEditor']//a/strong[contains(text(), 'WYSIWYG')]"));
View Full Code Here

Examples of org.xwiki.test.ui.framework.elements.ViewPage

    }

    @Test
    public void testUploadDownloadTwoAttachments()
    {
        ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), null,
            getTestClassName() + "#" + getTestMethodName());

        AttachmentsPane ap = vp.openAttachmentsDocExtraPane();
        ap.setFileToUpload(this.getClass().getResource("/" + this.testAttachment).getPath());
        ap.addAnotherFile();
        ap.setFileToUpload(this.getClass().getResource("/" + this.testAttachment2).getPath());
        ap.clickAttachFiles();
View Full Code Here

Examples of org.xwiki.test.ui.framework.elements.ViewPage

    public void testAttachAndViewGifImage()
    {
        // Prepare the page to display the GIF image. We explicitly set the width to a value greater than the actual
        // image width because we want the code that resizes the image on the server side to be executed (even if the
        // image is not actually resized).
        ViewPage viewPage = getUtil().createPage(getClass().getSimpleName(), getTestMethodName(),
            String.format("[[image:image.gif||width=%s]]", (20 + RandomUtils.nextInt(200))), getTestClassName());

        // Attach the GIF image.
        AttachmentsPane attachmentsPane = viewPage.openAttachmentsDocExtraPane();
        attachmentsPane.setFileToUpload(getClass().getResource("/image.gif").getPath());
        attachmentsPane.clickAttachFiles();
        // clickAttachFiles should wait for the page to load but it doesn't..
        viewPage.waitUntilPageIsLoaded();
        // XWIKI-5896 shows that the file name becomes image.png
        attachmentsPane = viewPage.openAttachmentsDocExtraPane();
        Assert.assertTrue(attachmentsPane.attachmentExistsByFileName("image.gif"));
    }
View Full Code Here

Examples of org.xwiki.test.ui.framework.elements.ViewPage

    public void testRollbackToFirstVersion() throws Exception
    {
        getUtil().deletePage(SPACE_NAME, PAGE_NAME);

        // Create first version of the page
        ViewPage vp = getUtil().createPage(SPACE_NAME, PAGE_NAME, CONTENT1, TITLE);

        // Adds second version
        WikiEditPage wikiEditPage = vp.editWiki();
        wikiEditPage.setContent(CONTENT2);
        wikiEditPage.clickSaveAndView();

        // TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
        // view mode) is fixed.
        vp.waitForDocExtraPaneActive("comments");

        // Verify that we can rollback to the first version
        HistoryTab historyTab = vp.openHistoryDocExtraPane();
        vp = historyTab.rollbackToVersion("1.1");

        // Rollback doesn't wait...
        // Wait for the comment tab to be selected since we're currently on the history tab and rolling
        // back is going to load a new page and make the focus active on the comments tab.
        vp.waitForDocExtraPaneActive("comments");

        Assert.assertEquals("First version of Content", vp.getContent());

        historyTab = vp.openHistoryDocExtraPane();
        Assert.assertEquals("Rollback to version 1.1", historyTab.getCurrentVersionComment());
        Assert.assertEquals("Administrator", historyTab.getCurrentAuthor());
    }
View Full Code Here

Examples of org.xwiki.test.ui.framework.elements.ViewPage

        WikiEditPage edit = new WikiEditPage();
        edit.switchToEdit("Test", "LanguageTest");
        edit.setContent("{{velocity}}context = ($context.language), doc = ($doc.language), "
            + "default = ($doc.defaultLanguage), tdoc = ($tdoc.language), "
            + "tdocdefault = ($tdoc.defaultLanguage){{/velocity}}");
        ViewPage vp = edit.clickSaveAndView();

        // Current language must be "en"
        Assert.assertEquals("Invalid content", vp.getContent(),
            "context = (en), doc = (), default = (en), tdoc = (), tdocdefault = (en)");

        // Change default language to "fr"
        this.adminPage.gotoPage();
        LocalizationAdministrationSectionPage sectionPage = this.adminPage.clickLocalizationSection();
        sectionPage.setDefaultLanguages("fr");
        sectionPage.clickSave();

        // Now language must be "fr"
        vp = getUtil().gotoPage("Test", "LanguageTest");
        Assert.assertTrue("Page not in French!", isPageInFrench());
        Assert.assertEquals("Invalid content", vp.getContent(),
            "context = (fr), doc = (), default = (en), tdoc = (), tdocdefault = (en)");
    }
View Full Code Here

Examples of org.xwiki.test.ui.framework.elements.ViewPage

    {
        WebElement html = getDriver().findElement(By.tagName("html"));
        Assert.assertEquals(language, html.getAttribute("lang"));
        Assert.assertEquals(language, html.getAttribute("xml:lang"));

        ViewPage vp = new ViewPage();
        Assert.assertEquals("locale=" + language, vp.getMetaDataValue("gwt:property"));
        Assert.assertEquals(language, vp.getMetaDataValue("language"));

        String content = getDriver().getPageSource();
        Assert.assertTrue(content.contains("language=" + language));
    }
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.