/// <summary> /// Gives a role permissions for a page that has already been created. /// </summary> /// <param name="setting">Grant, Deny, Unchecked</param> /// <param name="permission">The name of the Permission such as View, Edit, Add, Add Content etc.</param> /// <param name="pageName">The name of the page.</param> /// <param name="roleName">The name of the role.</param> public void SetPagePermissionForRole(string setting, string permission, string pageName, string roleName) { Span homeSpan = PageSpans.Filter(Find.ByText(s => s.Contains(pageName)))[0]; // Fires the left click event homeSpan.FireEvent("oncontextmenu"); Thread.Sleep(1000); PageSettingsLink.Click(); Thread.Sleep(1500); PageSettingsPage _pageSettings = new PageSettingsPage(this); _pageSettings.PermissionsTabLink.Click(); _pageSettings.SetPermissionForRole(setting, permission, roleName); _pageSettings.UpdatePageLink.Click(); Thread.Sleep(1500); }
/// <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); }