Exemplo n.º 1
0
        /// <summary>
        /// Creates a page with an HTML module and some content on it and then exports it.
        /// </summary>
        /// <param name="pageName">The page that will be created.</param>
        /// <param name="pageContent">The content to add to the HTML module on the page.</param>
        /// <param name="templateName">The name for the template.</param>
        /// <param name="withContent">Will the page be exported with content.</param>
        /// <param name="siteURL">The site url.</param>
        /// <param name="community">Is the site running community edition. Enter false if it uses professional or Enterprise.</param>
        public void CreateAndExportPage(string pageName, string pageContent, string templateName, bool withContent, string siteURL, bool community)
        {
            IconBar controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;

            //Add a page to the site
            if (ControlPanelElement.Id.Contains(RibbonBarID))
            {
                ribbonBar = new RibbonBar(this);
                ribbonBar.NewPageLink.ClickNoWait();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new IconBar(this);
                controlPanel.AddPageLink.ClickNoWait();
            }
            PageSettingsPage newPage = new PageSettingsPage(this);
            newPage.PageNameField.Value = pageName;
            newPage.PageTemplateSelect.Select("None Specified");
            newPage.SetPermissionForRole("Grant", "View", "All Users");
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);

            //Add content to the page 
            IEInstance.GoTo(siteURL + "/testpage.aspx");
            if (!usesRibbonBar)
            {
                if (community)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Export Module", "HTML", pageContent, 0);
                }
                else
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Export Module", "HTML Pro", pageContent, 0);
                }
            }
            else
            {
                if (community)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Export Module", "HTML", pageContent, 0);

                }
                else
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Export Module", "HTML Pro", pageContent, 0);

                }
            }

            //Act 
            if (usesRibbonBar)
            {
                ribbonBar.ExportPageLink.Click();
            }
            else
            {
                controlPanel.ExportPageLink.Click();
            }
            ExportTemplateFolderSelectList.Select("Templates");
            TemplateNameField.Value = templateName;
            TemplateDescriptionField.Value = "This is a template for testing";
            IncludeContentCheckbox.Checked = withContent;
            ExportLink.ClickNoWait();
            System.Threading.Thread.Sleep(1000);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a page with an HTML module and some content on it and then exports it.
        /// </summary>
        /// <param name="pageName">The page that will be created.</param>
        /// <param name="pageContent">The content to add to the HTML module on the page.</param>
        /// <param name="templateName">The name for the template.</param>
        /// <param name="withContent">Will the page be exported with content.</param>
        /// <param name="siteURL">The site url.</param>
        /// <param name="community">Is the site running community edition. Enter false if it uses professional or Enterprise.</param>
        public void CreateAndExportPage(string pageName, string pageContent, string templateName, bool withContent, string siteURL, bool community)
        {
            IconBar   controlPanel  = null;
            RibbonBar ribbonBar     = null;
            bool      usesRibbonBar = false;

            //Add a page to the site
            if (ControlPanelElement.Id.Contains(RibbonBarID))
            {
                ribbonBar = new RibbonBar(this);
                ribbonBar.NewPageLink.ClickNoWait();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new IconBar(this);
                controlPanel.AddPageLink.ClickNoWait();
            }
            PageSettingsPage newPage = new PageSettingsPage(this);

            newPage.PageNameField.Value = pageName;
            newPage.PageTemplateSelect.Select("None Specified");
            newPage.SetPermissionForRole("Grant", "View", "All Users");
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);

            //Add content to the page
            IEInstance.GoTo(siteURL + "/testpage.aspx");
            if (!usesRibbonBar)
            {
                if (community)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Export Module", "HTML", pageContent, 0);
                }
                else
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Export Module", "HTML Pro", pageContent, 0);
                }
            }
            else
            {
                if (community)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Export Module", "HTML", pageContent, 0);
                }
                else
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Export Module", "HTML Pro", pageContent, 0);
                }
            }

            //Act
            if (usesRibbonBar)
            {
                ribbonBar.ExportPageLink.Click();
            }
            else
            {
                controlPanel.ExportPageLink.Click();
            }
            ExportTemplateFolderSelectList.Select("Templates");
            TemplateNameField.Value        = templateName;
            TemplateDescriptionField.Value = "This is a template for testing";
            IncludeContentCheckbox.Checked = withContent;
            ExportLink.ClickNoWait();
            System.Threading.Thread.Sleep(1000);
        }