package test_classes; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.TimeUnit; import org.apache.commons.io.FilenameUtils; import org.openqa.selenium.By; import org.testng.SkipException; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import abstract_classes.BaseTest; import qsf_page_object_pattern.BackEnd.BackEnd_CmsEditPage; import qsf_page_object_pattern.BackEnd.BackEnd_CmsPage; import qsf_page_object_pattern.BackEnd.BackEnd_CmsReorderPage; import qsf_page_object_pattern.FrontEnd.FrontEnd_CmsPage; import qsf_page_object_pattern.FrontEnd.FrontEnd_SiteMapPage; import tools.DynamicDataProvider; public class be_cms_test extends BaseTest{ final static String addedAlert = "Page has been added"; final String updatedAlert = "Page has been updated"; final static String deletedAlert = "Page has been deleted"; final String reorderedAlert = "Pages have been reordered"; String menuTitleCurrent; String menuTitleSubpageCurrent; String anotherMenuTitleCurrent; String anotherMenuTitleSubpageCurrent; String parentAlias; final String modulePath = "site-content/cms"; DynamicDataProvider dp = new DynamicDataProvider("BE_CmsPage.json"); @DataProvider(name = "Incorrect_Data") public Object[][] createData2() { return dp.GenerateFullCheck(); } @DataProvider(name = "Valid_Data") public Object[][] createData1() { return dp.GenerateTreeRecord("existingValue"); } @DataProvider(name = "Default_Data") public Object[][] createData5() { return dp.GenerateTreeRecord("defaultValue"); } @DataProvider(name = "Edit_Data") public Object[][] createData3() { return dp.GenerateTreeRecord("editValue"); } @DataProvider(name = "CleanUp_Data") public Object[][] createData4() { return dp.GenerateTreeRecord("editValue"); //return ArrayUtils.addAll(dp.GenerateFullCheck(), dp.GenerateTreeRecord("editValue")); } @Parameters({"browser"}) @BeforeClass public void SetUp(@Optional("Firefox") String browser){ SetDriver(browser); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); loginToAdmin(); } @Test(dataProvider = "Valid_Data", description = "") public void TestValidCmsPage(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath + "?action=new"); BackEnd_CmsEditPage be_cmsEditPage = new BackEnd_CmsEditPage(driver); be_cmsEditPage.expandFckEditorFields(); BackEnd_CmsPage be_cmsPage = be_cmsEditPage.addNew(fields); assertTrue(be_cmsPage.getAlertInfo().contains(addedAlert), "Expected '"+addedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); menuTitleCurrent = fields.get("meta[menuTitle]").get("value"); be_cmsEditPage = be_cmsPage.editRecord(menuTitleCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestValidCmsPage", priority=1, description = "") public void TestFrontEnd(Map> fields){ driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value").toString()); FrontEnd_CmsPage fe_cmsPage = new FrontEnd_CmsPage(driver); for(Entry> field : fields.entrySet()){ if(fe_cmsPage.getFrontEndValue(field.getKey())!=null){ switch (field.getKey()) { case "content":{ assertTrue(fe_cmsPage.getFrontEndValue(field.getKey()).contains(field.getValue().get("value")), "Value for '"+field.getKey()+"' did not match with Front End"); } break; case "meta[title]":{ assertTrue(fe_cmsPage.getFrontEndValue(field.getKey()).contains(field.getValue().get("value")), "Value for '"+field.getKey()+"' did not match with Front End"); } break; case "headerImage":{ String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(fe_cmsPage.getFrontEndValue(field.getKey()).contains(fileNameWithOutExt), "Value for '"+field.getKey()+"' did not match with Front End"); } break; default:{ assertEquals(fe_cmsPage.getFrontEndValue(field.getKey()), field.getValue().get("value"), "Value for '"+field.getKey()+"' did not match with Front End"); } } } } driver.get(settings.http + settings.siteUrl + "site-map.html"); FrontEnd_SiteMapPage fe_siteMapPage = new FrontEnd_SiteMapPage(driver); List sitemapItems = fe_siteMapPage.getSiteMapItems(); assertTrue(sitemapItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was not found on Site Map"); List topLevelMenuItems = fe_siteMapPage.getTopLevelMenuByOrder(); assertTrue(topLevelMenuItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was not found in Main Menu"); ListfooterItems = fe_cmsPage.getFooterItemsByOrder(); assertTrue(footerItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was not found in Footer"); } @Test(dataProvider = "Incorrect_Data", dependsOnMethods="TestValidCmsPage", priority=2, enabled=true, description = "") public void TestIncorrectCmsItem(Map> fieldsData, Map> expectedErrors) throws InterruptedException{ driver.get(settings.http + settings.adminUrl + modulePath + "?action=new"); BackEnd_CmsEditPage be_cmsEditPage = new BackEnd_CmsEditPage(driver); //be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); be_cmsEditPage = be_cmsEditPage.submitIncorrectData(fieldsData); Map>realFormErrors = be_cmsEditPage.getFieldsAlerts(); compareFormErrors(realFormErrors, expectedErrors); } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestValidCmsPage", priority=3, description = "") public void TestEditCmsPage(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.editRecord(menuTitleCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); be_cmsPage = be_cmsEditPage.addNew(fields); assertTrue(be_cmsPage.getAlertInfo().contains(updatedAlert), "Expected '"+updatedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); menuTitleCurrent = fields.get("meta[menuTitle]").get("value"); be_cmsEditPage = be_cmsPage.editRecord(menuTitleCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestEditCmsPage", priority=4, description = "") public void TestDisabledItemFrontEnd(Map> fields){ driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value").toString()); waitForPageLoaded(); assertTrue(driver.findElement(By.tagName("body")).getText().contains("404 - Not Found"), "This is not 404 page"); } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestEditCmsPage", priority=5, description = "") public void TestAnotherValidCmsPage(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath + "?action=new"); BackEnd_CmsEditPage be_cmsEditPage = new BackEnd_CmsEditPage(driver); be_cmsEditPage.expandFckEditorFields(); BackEnd_CmsPage be_cmsPage = be_cmsEditPage.addNew(fields); assertTrue(be_cmsPage.getAlertInfo().contains(addedAlert), "Expected '"+addedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); parentAlias = fields.get("meta[alias]").get("value"); anotherMenuTitleCurrent = fields.get("meta[menuTitle]").get("value"); be_cmsEditPage = be_cmsPage.editRecord(anotherMenuTitleCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Incorrect_Data", dependsOnMethods="TestEditCmsPage", priority=6, enabled=true, description = "") public void TestIncorrectEditCmsItem(Map> fieldsData, Map> expectedErrors) throws InterruptedException{ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.editRecord(menuTitleCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); Map> clearData = dp.GenerateClearForm(); be_cmsEditPage.clearForm(clearData); be_cmsEditPage = be_cmsEditPage.submitIncorrectData(fieldsData); Map>realFormErrors = be_cmsEditPage.getFieldsAlerts(); compareFormErrors(realFormErrors, expectedErrors); } @Test(dataProvider = "Incorrect_Data", dependsOnMethods="TestEditCmsPage", priority=7, enabled=true, description = "") public void TestIncorrectEditDraftPage(Map> fieldsData, Map> expectedErrors) throws InterruptedException{ if(expectedErrors.containsKey("headerImage")){ throw new SkipException("headerImage is unable to test during draft testing."); } driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.editRecord(menuTitleCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); Map> clearData = dp.GenerateClearForm(); be_cmsEditPage.clearForm(clearData); be_cmsEditPage = be_cmsEditPage.submitIncorrectDraft(fieldsData); Map>realFormErrors = be_cmsEditPage.getFieldsAlerts(); compareFormErrors(realFormErrors, expectedErrors); } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestEditCmsPage", priority=8) public void TestDeleteCmsPage(Map> fields) { driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); be_cmsPage = be_cmsPage.deletePage(fields.get("meta[menuTitle]").get("value")); assertTrue(be_cmsPage.getAlertInfo().contains(deletedAlert), "Expected '"+deletedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestAnotherValidCmsPage", priority=9) public void TestEnablingVisibility(Map> fields){ //test Show in Sitemap driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.editRecord(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.inputFormFieldValue("meta[showInSiteMap]", "false", "checkbox"); be_cmsPage = be_cmsEditPage.submitForm(); assertTrue(be_cmsPage.getAlertInfo().contains(updatedAlert), "Expected '"+updatedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); driver.get(settings.http + settings.siteUrl + "site-map.html"); FrontEnd_SiteMapPage fe_siteMapPage = new FrontEnd_SiteMapPage(driver); ListsitemapItems = fe_siteMapPage.getSiteMapItems(); assertFalse(sitemapItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was disabled for sitemap but it is still visible"); //test Show in Menu driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editRecord(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.inputFormFieldValue("meta[showInSiteMap]", "true", "checkbox"); be_cmsEditPage.inputFormFieldValue("meta[showInMenu]", "false", "checkbox"); be_cmsPage = be_cmsEditPage.submitForm(); assertTrue(be_cmsPage.getAlertInfo().contains(updatedAlert), "Expected '"+updatedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value").toString()); FrontEnd_CmsPage fe_cmsPage = new FrontEnd_CmsPage(driver); ListtopLevelMenuItems = fe_cmsPage.getTopLevelMenuByOrder(); assertFalse(topLevelMenuItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was disabled for menu but it is still visible"); driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editRecord(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.inputFormFieldValue("meta[showInMenu]", "true", "checkbox"); be_cmsEditPage.inputFormFieldValue("meta[showInFooter]", "false", "checkbox"); be_cmsPage = be_cmsEditPage.submitForm(); assertTrue(be_cmsPage.getAlertInfo().contains(updatedAlert), "Expected '"+updatedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value").toString()); fe_cmsPage = new FrontEnd_CmsPage(driver); ListfooterItems = fe_cmsPage.getFooterItemsByOrder(); assertFalse(footerItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was disabled for menu but it is still visible"); //test Show in Show on user end driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editRecord(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.inputFormFieldValue("meta[showInFooter]", "true", "checkbox"); be_cmsEditPage.inputFormFieldValue("meta[enabled]", "false", "checkbox"); be_cmsPage = be_cmsEditPage.submitForm(); driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value").toString()); waitForPageLoaded(); assertTrue(driver.findElement(By.tagName("body")).getText().contains("404 - Not Found"), "This is not 404 page"); driver.get(settings.http + settings.siteUrl + "site-map.html"); fe_siteMapPage = new FrontEnd_SiteMapPage(driver); sitemapItems = fe_siteMapPage.getSiteMapItems(); assertFalse(sitemapItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was disabled for sitemap but it is still visible"); topLevelMenuItems = fe_siteMapPage.getTopLevelMenuByOrder(); assertFalse(topLevelMenuItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was disabled for menu but it is still visible"); //return to normal driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editRecord(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.inputFormFieldValue("meta[enabled]", "true", "checkbox"); be_cmsPage = be_cmsEditPage.submitForm(); } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestAnotherValidCmsPage", priority=10) public void TestReorderCmsItems(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); ListtitleOrder = be_cmsPage.getCmsTitlesByOrder(); Integer lastIndex = titleOrder.indexOf(fields.get("meta[menuTitle]").get("value")); BackEnd_CmsReorderPage be_cmsReorderPage = be_cmsPage.openReorderPage(); be_cmsPage = be_cmsReorderPage.moveElementToTop(fields.get("meta[menuTitle]").get("value")); assertTrue(be_cmsPage.getAlertInfo().contains(reorderedAlert), "Expected '"+reorderedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); titleOrder = be_cmsPage.getCmsTitlesByOrder(); assertEquals(titleOrder.get(0), fields.get("meta[menuTitle]").get("value")); driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value")); FrontEnd_CmsPage fe_cmsPage = new FrontEnd_CmsPage(driver); List menuOrder = fe_cmsPage.getTopLevelMenuByOrder(); assertEquals(menuOrder.get(0), fields.get("meta[menuTitle]").get("value")); driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsReorderPage = be_cmsPage.openReorderPage(); be_cmsPage = be_cmsReorderPage.moveElementToBottom(fields.get("meta[menuTitle]").get("value")); assertTrue(be_cmsPage.getAlertInfo().contains(reorderedAlert), "Expected '"+reorderedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); titleOrder = be_cmsPage.getCmsTitlesByOrder(); assertEquals(titleOrder.get(lastIndex), fields.get("meta[menuTitle]").get("value")); driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value")); fe_cmsPage = new FrontEnd_CmsPage(driver); menuOrder = fe_cmsPage.getTopLevelMenuByOrder(); assertEquals(menuOrder.get(menuOrder.size() - 1), fields.get("meta[menuTitle]").get("value")); } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestDeleteCmsPage", priority=11) public void TestDraftsSaving(Map> fields){ fields.remove("headerImage"); driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); //test Meta Draft BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.editRecord(anotherMenuTitleCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); be_cmsEditPage = be_cmsEditPage.saveMetaDraft(fields); driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editRecord(anotherMenuTitleCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ if(!field.getKey().equals("content")){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } else{ assertFalse(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } //Test Content Draft be_cmsEditPage = be_cmsEditPage.saveContentDraft(fields); driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editRecord(anotherMenuTitleCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestDraftsSaving", priority=12, description = "") public void TestPageWithDraftsFrontEnd(Map> fields){ driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value")); FrontEnd_CmsPage fe_cmsPage = new FrontEnd_CmsPage(driver); for(Entry> field : fields.entrySet()){ if(fe_cmsPage.getFrontEndValue(field.getKey())!=null){ switch (field.getKey()) { case "content":{ assertTrue(fe_cmsPage.getFrontEndValue(field.getKey()).contains(field.getValue().get("value")), "Value for '"+field.getKey()+"' did not match with Front End"); } break; case "meta[title]":{ assertTrue(fe_cmsPage.getFrontEndValue(field.getKey()).contains(field.getValue().get("value")), "Value for '"+field.getKey()+"' did not match with Front End"); } break; case "headerImage":{ String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(fe_cmsPage.getFrontEndValue(field.getKey()).contains(fileNameWithOutExt), "Value for '"+field.getKey()+"' did not match with Front End"); } break; default:{ assertEquals(fe_cmsPage.getFrontEndValue(field.getKey()), field.getValue().get("value"), "Value for '"+field.getKey()+"' did not match with Front End"); } } } } driver.get(settings.http + settings.siteUrl + "site-map.html"); FrontEnd_SiteMapPage fe_siteMapPage = new FrontEnd_SiteMapPage(driver); List sitemapItems = fe_siteMapPage.getSiteMapItems(); assertTrue(sitemapItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was not found on Site Map"); List topLevelMenuItems = fe_siteMapPage.getTopLevelMenuByOrder(); assertTrue(topLevelMenuItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was not found in Main Menu"); } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestDraftsSaving", priority=13) public void TestCancelAllDrafts(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage= be_cmsPage.editRecord(fields.get("meta[menuTitle]").get("value")); be_cmsPage = be_cmsEditPage.cancelAllDrafts(); be_cmsEditPage= be_cmsPage.editRecord(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestCancelAllDrafts") public void TestValidSubpage(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.addSubPage(fields.get("meta[menuTitle]").get("value")); //be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); be_cmsPage = be_cmsEditPage.addNew(fields); assertTrue(be_cmsPage.getAlertInfo().contains(addedAlert), "Expected '"+addedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); menuTitleSubpageCurrent = fields.get("meta[menuTitle]").get("value"); be_cmsEditPage = be_cmsPage.editSubPage(menuTitleSubpageCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestValidSubpage", priority=1, description = "") public void TestSubpageFrontEnd(Map> fields){ driver.get(settings.http + settings.siteUrl + parentAlias +"/"+fields.get("meta[alias]").get("value")); FrontEnd_CmsPage fe_cmsPage = new FrontEnd_CmsPage(driver); for(Entry> field : fields.entrySet()){ if(fe_cmsPage.getFrontEndValue(field.getKey())!=null){ switch (field.getKey()) { case "content":{ assertTrue(fe_cmsPage.getFrontEndValue(field.getKey()).contains(field.getValue().get("value")), "Value for '"+field.getKey()+"' did not match with Front End"); } break; case "meta[title]":{ assertTrue(fe_cmsPage.getFrontEndValue(field.getKey()).contains(field.getValue().get("value")), "Value for '"+field.getKey()+"' did not match with Front End"); } break; case "headerImage":{ String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(fe_cmsPage.getFrontEndValue(field.getKey()).contains(fileNameWithOutExt), "Value for '"+field.getKey()+"' did not match with Front End"); } break; default:{ assertEquals(fe_cmsPage.getFrontEndValue(field.getKey()), field.getValue().get("value"), "Value for '"+field.getKey()+"' did not match with Front End"); } } } } driver.get(settings.http + settings.siteUrl + "site-map.html"); FrontEnd_SiteMapPage fe_siteMapPage = new FrontEnd_SiteMapPage(driver); List sitemapItems = fe_siteMapPage.getSiteMapItems(fields.get("meta[menuTitle]").get("value")); assertTrue(sitemapItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was not found on Site Map"); List parrentMenuItems = fe_siteMapPage.getSubmenuByParent(fields.get("meta[menuTitle]").get("value")); assertTrue(parrentMenuItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was not found in Main Menu"); } @Test(dataProvider = "Incorrect_Data", dependsOnMethods="TestValidSubpage", priority=2, enabled=true, description = "") public void TestIncorrectCmsSubpageItem(Map> fieldsData, Map> expectedErrors) throws InterruptedException{ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.addSubPage(menuTitleSubpageCurrent); //be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); be_cmsEditPage = be_cmsEditPage.submitIncorrectData(fieldsData); Map>realFormErrors = be_cmsEditPage.getFieldsAlerts(); compareFormErrors(realFormErrors, expectedErrors); } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestValidSubpage", priority=3, description = "") public void TestEditCmsSubPage(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.editSubPage(menuTitleSubpageCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); be_cmsPage = be_cmsEditPage.addNew(fields); assertTrue(be_cmsPage.getAlertInfo().contains(updatedAlert), "Expected '"+updatedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); menuTitleSubpageCurrent = fields.get("meta[menuTitle]").get("value"); be_cmsEditPage = be_cmsPage.editSubPage(menuTitleSubpageCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestEditCmsSubPage", priority=4, description = "") public void TestDisabledSubPageFrontEnd(Map> fields){ driver.get(settings.http + settings.siteUrl + parentAlias +"/" + fields.get("meta[alias]").get("value").toString()); waitForPageLoaded(); assertTrue(driver.findElement(By.tagName("body")).getText().contains("404 - Not Found"), "This is not 404 page"); } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestEditCmsSubPage", priority=5, description = "") public void TestAnotherValidSubpage(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.addSubPage(fields.get("meta[menuTitle]").get("value")); //be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); be_cmsPage = be_cmsEditPage.addNew(fields); assertTrue(be_cmsPage.getAlertInfo().contains(addedAlert), "Expected '"+addedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); anotherMenuTitleSubpageCurrent = fields.get("meta[menuTitle]").get("value"); be_cmsEditPage = be_cmsPage.editSubPage(anotherMenuTitleSubpageCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Incorrect_Data", dependsOnMethods="TestEditCmsSubPage", priority=6, enabled=true, description = "") public void TestIncorrectEditCmsSubPageItem(Map> fieldsData, Map> expectedErrors) throws InterruptedException{ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.editSubPage(menuTitleSubpageCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); Map> clearData = dp.GenerateClearForm(); be_cmsEditPage.clearForm(clearData); be_cmsEditPage = be_cmsEditPage.submitIncorrectData(fieldsData); Map>realFormErrors = be_cmsEditPage.getFieldsAlerts(); compareFormErrors(realFormErrors, expectedErrors); } @Test(dataProvider = "Incorrect_Data", dependsOnMethods="TestEditCmsSubPage", priority=7, enabled=true, description = "") public void TestIncorrectEditDraftSubPage(Map> fieldsData, Map> expectedErrors) throws InterruptedException{ if(expectedErrors.containsKey("headerImage")){ throw new SkipException("headerImage is unable to test during draft testing."); } driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.editSubPage(menuTitleSubpageCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); Map> clearData = dp.GenerateClearForm(); be_cmsEditPage.clearForm(clearData); be_cmsEditPage = be_cmsEditPage.submitIncorrectDraft(fieldsData); Map>realFormErrors = be_cmsEditPage.getFieldsAlerts(); compareFormErrors(realFormErrors, expectedErrors); } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestEditCmsSubPage", priority=8) public void TestDeleteCmsSubPage(Map> fields) { driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); be_cmsPage = be_cmsPage.deleteSubPage(fields.get("meta[menuTitle]").get("value")); assertTrue(be_cmsPage.getAlertInfo().contains(deletedAlert), "Expected '"+deletedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestAnotherValidSubpage", priority=9) public void TestEnablingVisibilitySubpage(Map> fields){ //test Show in Sitemap driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.editSubPage(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.inputFormFieldValue("meta[showInSiteMap]", "false", "checkbox"); be_cmsPage = be_cmsEditPage.submitForm(); assertTrue(be_cmsPage.getAlertInfo().contains(updatedAlert), "Expected '"+updatedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); driver.get(settings.http + settings.siteUrl + "site-map.html"); FrontEnd_SiteMapPage fe_siteMapPage = new FrontEnd_SiteMapPage(driver); ListsitemapItems = fe_siteMapPage.getSiteMapItems(fields.get("meta[menuTitle]").get("value")); assertFalse(sitemapItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was disabled for sitemap but it is still visible"); //test Show in Menu driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editSubPage(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.inputFormFieldValue("meta[showInSiteMap]", "true", "checkbox"); be_cmsEditPage.inputFormFieldValue("meta[showInMenu]", "false", "checkbox"); be_cmsPage = be_cmsEditPage.submitForm(); assertTrue(be_cmsPage.getAlertInfo().contains(updatedAlert), "Expected '"+updatedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value").toString()); FrontEnd_CmsPage fe_cmsPage = new FrontEnd_CmsPage(driver); ListsubMenuItems = fe_cmsPage.getSubmenuByParent(fields.get("meta[menuTitle]").get("value")); assertFalse(subMenuItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was disabled for menu but it is still visible"); //test Show in Footer driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editSubPage(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.inputFormFieldValue("meta[showInMenu]", "true", "checkbox"); be_cmsEditPage.inputFormFieldValue("meta[showInFooter]", "false", "checkbox"); be_cmsPage = be_cmsEditPage.submitForm(); assertTrue(be_cmsPage.getAlertInfo().contains(updatedAlert), "Expected '"+updatedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value").toString()); fe_cmsPage = new FrontEnd_CmsPage(driver); ListfooterItems = fe_cmsPage.getFooterItemsByParent(fields.get("meta[alias]").get("value")); assertFalse(footerItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was disabled for menu but it is still visible"); //test Show on user end driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editSubPage(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.inputFormFieldValue("meta[showInFooter]", "true", "checkbox"); be_cmsEditPage.inputFormFieldValue("meta[enabled]", "false", "checkbox"); be_cmsPage = be_cmsEditPage.submitForm(); driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value") + "/" + fields.get("meta[alias]").get("value")); waitForPageLoaded(); assertTrue(driver.findElement(By.tagName("body")).getText().contains("404 - Not Found"), "This is not 404 page"); driver.get(settings.http + settings.siteUrl + "site-map.html"); fe_siteMapPage = new FrontEnd_SiteMapPage(driver); sitemapItems = fe_siteMapPage.getSiteMapItems(fields.get("meta[menuTitle]").get("value")); assertFalse(sitemapItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was disabled for sitemap but it is still visible"); subMenuItems = fe_siteMapPage.getSubmenuByParent(fields.get("meta[menuTitle]").get("value")); assertFalse(subMenuItems.contains(fields.get("meta[menuTitle]").get("value")), "Page '"+fields.get("meta[menuTitle]").get("value")+"' was disabled for menu but it is still visible"); //return to normal driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editSubPage(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.inputFormFieldValue("meta[enabled]", "true", "checkbox"); be_cmsPage = be_cmsEditPage.submitForm(); } @Test(dataProvider = "Default_Data", dependsOnMethods="TestAnotherValidSubpage", priority=10, description = "") public void TestDefaultSubpage(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.addSubPage(anotherMenuTitleCurrent); //be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); be_cmsPage = be_cmsEditPage.addNew(fields); assertTrue(be_cmsPage.getAlertInfo().contains(addedAlert), "Expected '"+addedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); //anotherMenuTitleSubpageCurrent = fields.get("meta[menuTitle]").get("value"); be_cmsEditPage = be_cmsPage.editSubPage(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestAnotherValidSubpage", priority=11) public void TestReorderSubPageItems(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); ListtitleOrder = be_cmsPage.getCmsTitlesByOrder(fields.get("meta[menuTitle]").get("value")); Integer lastIndex = titleOrder.size()-1; BackEnd_CmsReorderPage be_cmsReorderPage = be_cmsPage.openReorderPage(fields.get("meta[menuTitle]").get("value")); be_cmsPage = be_cmsReorderPage.moveElementToBottom(fields.get("meta[menuTitle]").get("value")); assertTrue(be_cmsPage.getAlertInfo().contains(reorderedAlert), "Expected '"+reorderedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); titleOrder = be_cmsPage.getCmsTitlesByOrder(fields.get("meta[menuTitle]").get("value")); assertEquals(titleOrder.get(lastIndex), fields.get("meta[menuTitle]").get("value")); driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value")); FrontEnd_CmsPage fe_cmsPage = new FrontEnd_CmsPage(driver); List menuOrder = fe_cmsPage.getSubmenuByParent(fields.get("meta[menuTitle]").get("value")); assertEquals(menuOrder.get(menuOrder.size() - 1), fields.get("meta[menuTitle]").get("value")); driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsReorderPage = be_cmsPage.openReorderPage(fields.get("meta[menuTitle]").get("value")); be_cmsPage = be_cmsReorderPage.moveElementToTop(fields.get("meta[menuTitle]").get("value")); assertTrue(be_cmsPage.getAlertInfo().contains(reorderedAlert), "Expected '"+reorderedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); titleOrder = be_cmsPage.getCmsTitlesByOrder(fields.get("meta[menuTitle]").get("value")); assertEquals(titleOrder.get(0), fields.get("meta[menuTitle]").get("value")); driver.get(settings.http + settings.siteUrl + fields.get("meta[alias]").get("value")); fe_cmsPage = new FrontEnd_CmsPage(driver); menuOrder = fe_cmsPage.getSubmenuByParent(fields.get("meta[menuTitle]").get("value")); assertEquals(menuOrder.get(0), fields.get("meta[menuTitle]").get("value")); } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestDeleteCmsSubPage", priority=12) public void TestSubpageDraftsSaving(Map> fields){ fields.remove("headerImage"); driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); //test Meta Draft BackEnd_CmsEditPage be_cmsEditPage = be_cmsPage.editSubPage(anotherMenuTitleCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); be_cmsEditPage = be_cmsEditPage.saveMetaDraft(fields); driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editSubPage(anotherMenuTitleSubpageCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ if(!field.getKey().equals("content")){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } else{ assertFalse(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } //Test Content Draft be_cmsEditPage = be_cmsEditPage.saveContentDraft(fields); driver.get(settings.http + settings.adminUrl + modulePath); be_cmsPage = new BackEnd_CmsPage(driver); be_cmsEditPage = be_cmsPage.editSubPage(anotherMenuTitleSubpageCurrent); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestSubpageDraftsSaving", priority=13) public void TestCancelAllDraftsSubPage(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); BackEnd_CmsEditPage be_cmsEditPage= be_cmsPage.editSubPage(fields.get("meta[menuTitle]").get("value")); be_cmsPage = be_cmsEditPage.cancelAllDrafts(); be_cmsEditPage= be_cmsPage.editSubPage(fields.get("meta[menuTitle]").get("value")); be_cmsEditPage.openEditMeta(); be_cmsEditPage.expandFckEditorFields(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "undefined-fck-editor": { assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(field.getValue().get("value")), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } break; case "file": { String fileNameWithOutExt = FilenameUtils.removeExtension(field.getValue().get("value")); assertTrue(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_cmsEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")), field.getValue().get("value"), "Values in Edit Mode for "+field.getKey()+"do not match with input values"); } } } @Test(dataProvider = "Valid_Data", dependsOnMethods="TestSubpageDraftsSaving", priority=14, description = "") public void cleanUpCms(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); be_cmsPage = be_cmsPage.deletePage(fields.get("meta[menuTitle]").get("value")); assertTrue(be_cmsPage.getAlertInfo().contains(deletedAlert), "Expected '"+deletedAlert+"' to appear on page, but found: '"+be_cmsPage.getAlertInfo()+"'"); } @Test(priority=7, description = "") public void testCancelButtons() throws InterruptedException{ driver.get(settings.http + settings.adminUrl + modulePath + "?action=new"); BackEnd_CmsEditPage be_cmsEditPage = new BackEnd_CmsEditPage(driver); be_cmsEditPage.expandFckEditorFields(); Thread.sleep(1000); be_cmsEditPage.closeEditMeta(); be_cmsEditPage.collapseFckEditorFields(); be_cmsEditPage = new BackEnd_CmsEditPage(driver); } @Test public void testMangeButtons(){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_CmsPage be_cmsPage = new BackEnd_CmsPage(driver); ListmanageUrls = be_cmsPage.getManageUrls(); for(String url : manageUrls){ driver.get(url); waitForPageLoaded(); assertFalse(driver.findElement(By.tagName("body")).getText().contains("404 - Not Found"), "404 Error was found on '"+url+"'"); } } @AfterClass public void tearDown(){ driver.quit(); //driver.close(); } }