public void LoginToSite() { var doc = XDocument.Load(@"P1\" + Settings.Default.P1DataFile); XElement settings = doc.Document.Element("Tests").Element("settings"); XElement pageSettings = doc.Document.Element("Tests").Element("page"); string testName = pageSettings.Attribute("name").Value; _driver = StartBrowser(settings.Attribute("browser").Value); _baseUrl = settings.Attribute("baseURL").Value; Trace.WriteLine(BasePage.RunningTestKeyWord + "'" + testName + "'"); Trace.WriteLine(BasePage.PreconditionsKeyWord); MainPage mainPage = new MainPage(_driver); mainPage.OpenUsingUrl(_baseUrl); _loginPage = new LoginPage(_driver); _loginPage.OpenUsingUrl(_baseUrl); _loginPage.DoLoginUsingUrl("host", "dnnhost"); //Preconditions for AdminPageManagementPage adminPageManagementPage = new AdminPageManagementPage(_driver); adminPageManagementPage.OpenUsingButtons(_baseUrl); adminPageManagementPage.AddPagesInBulk("Page", 73, "Web", "Home"); BlankPage blankPage = new BlankPage(_driver); Modules module = new Modules(_driver); int pageNumber = 1; while (pageNumber < 74) { blankPage.OpenUsingUrl(_baseUrl, "Home/Page" + pageNumber); blankPage.SetPageToEditMode("Home/Page" + pageNumber); string moduleNumber = module.WaitForElement(By.XPath(Modules.ContentPaneID + Modules.HtmlProModuleOnPage + "/a")).GetAttribute("name"); module.DeleteModule(moduleNumber); pageNumber++; } blankPage.OpenUsingUrl(_baseUrl, "Home/Page61"); module.OpenModulePanelUsingControlPanel(); int i = 1; while (i < 5) { module.AddNewModuleUsingMenu(Modules.HtmlProModule, Modules.HtmlProModuleOnPage, Modules.ContentPaneOption, Modules.ContentPaneID); i++; } }
public void Test002_EditDefaultHTMLModuleOnPage() { Trace.WriteLine(BasePage.RunningTestKeyWord + "'Edit Default HTML Module on the Page'"); BlankPage blankPage = new BlankPage(_driver); blankPage.OpenUsingUrl(_baseUrl, _pageName); blankPage.SetPageToEditMode(_pageName); Modules module = new Modules(_driver); Trace.WriteLine(BasePage.TraceLevelElement + "Find the Module number:"); string moduleNumber = module.WaitForElement(By.XPath(Modules.HtmlProModuleOnPage + "/a")).GetAttribute("name"); module.AddContentToHTMLProModule(moduleNumber, _pageContent); Trace.WriteLine(BasePage.TraceLevelPage + "ASSERT the Module content is present on the screen"); Assert.That(blankPage.FindElement(By.XPath("//div[contains(@class, 'DNN_HTML DnnModule-')]//div[contains(@id, 'lblContent')]")).Text, Is.EqualTo(_pageContent)); }
public void Test0014_EditContentOfExistingModule(string pageName, string moduleContent) { Trace.WriteLine(BasePage.RunningTestKeyWord + "'Edit content to HTML Module'"); Modules module = new Modules(_driver); MainPage mainPage = new MainPage(_driver); mainPage.OpenUsingUrl(_baseUrl); Trace.WriteLine(BasePage.TraceLevelPage + "Find the original module number on 'Home' page"); string originalModuleNumber = mainPage.WaitForElement(By.XPath(Modules.FooterRightPaneID + "/div[last()]/a")).GetAttribute("name"); BlankPage blankPage = new BlankPage(_driver); blankPage.OpenUsingUrl(_baseUrl, pageName); blankPage.SetPageToEditMode(pageName); Trace.WriteLine(BasePage.TraceLevelElement + "Find the Module number:"); string moduleNumberOnNewPage = module.WaitForElement(By.XPath(Modules.ContentPaneID + Modules.HtmlProModuleOnPage + "/a")).GetAttribute("name"); module.AddContentToHTMLProModule(moduleNumberOnNewPage, moduleContent); Trace.WriteLine(BasePage.TraceLevelPage + "ASSERT the module Content is present on the page"); Assert.That(moduleContent, Is.EqualTo(module.FindElement(By.XPath("//div[contains(@class, 'DNN_HTML DnnModule-" + moduleNumberOnNewPage + "')]//div[contains(@id, 'lblContent')]")).Text)); mainPage.OpenUsingUrl(_baseUrl); Trace.WriteLine(BasePage.TraceLevelPage + "ASSERT the module Content changed on 'Home' page"); Assert.That(moduleContent, Is.Not.EqualTo(module.WaitForElement(By.XPath("//div[contains(@class, 'DNN_HTML DnnModule-" + originalModuleNumber + "')]//div[contains(@id, 'lblContent')]")).Text)); }
public void Test008_DragAndDropModuleToLeftPane(string pageName, string moduleNameOnPage, string newLocationID) { Modules module = new Modules(_driver); var fiModuleNameOnPage = module.GetType().GetField(moduleNameOnPage); moduleNameOnPage = (string)fiModuleNameOnPage.GetValue(null); var fiNewLocationID = module.GetType().GetField(newLocationID); newLocationID = (string)fiNewLocationID.GetValue(null); Trace.WriteLine(BasePage.RunningTestKeyWord + "'Drag and drop a Module'"); BlankPage blankPage = new BlankPage(_driver); blankPage.OpenUsingUrl(_baseUrl, pageName); blankPage.SetPageToEditMode(pageName); string moduleNumber = blankPage.WaitForElement(By.XPath(moduleNameOnPage + "/a")).GetAttribute("name"); module.MoveModuleUsingDragAndDrop(moduleNumber, moduleNameOnPage, newLocationID); blankPage.OpenUsingUrl(_baseUrl, pageName); Trace.WriteLine(BasePage.TraceLevelPage + "ASSERT the Module new location: " + newLocationID + moduleNameOnPage); Assert.IsTrue(blankPage.ElementPresent(By.XPath(newLocationID + moduleNameOnPage)), "Module is not found"); }