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.openqa.selenium.WebElement; 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_FaqAddPage; import qsf_page_object_pattern.BackEnd.BackEnd_FaqCategoryAddPage; import qsf_page_object_pattern.BackEnd.BackEnd_FaqCategoryEditPage; import qsf_page_object_pattern.BackEnd.BackEnd_FaqCategoryPage; import qsf_page_object_pattern.BackEnd.BackEnd_FaqCategoryReorderPage; import qsf_page_object_pattern.BackEnd.BackEnd_FaqEditPage; import qsf_page_object_pattern.BackEnd.BackEnd_FaqPage; //import qsf_page_object_pattern.BackEnd.BackEnd_NewsAddPage; //import qsf_page_object_pattern.BackEnd.BackEnd_NewsPage; import qsf_page_object_pattern.FrontEnd.FrontEnd_FaqPage; import tools.DynamicDataProvider; public class be_faq_test extends BaseTest{ final String addedAlert = "FAQ has been added"; final String updatedAlert = "FAQ has been updated"; final String deletedAlert = "FAQ has been deleted"; final String addedCategoryAlert = "FAQ Category has been added"; final String updatedCategoryAlert = "FAQ Category has been updated"; final String deletedCategoryAlert = "FAQ Category has been deleted"; final String reorderedCategoryAlert = "FAQ Categories have been reordered"; final String modulePath = "site-content/faq"; final String moduleCatPath = "site-content/faq/category"; final String moduleFrontEndPath = "company/faq"; DynamicDataProvider dp = new DynamicDataProvider("BE_Faq.json"); DynamicDataProvider category_dp = new DynamicDataProvider("BE_FaqCategory.json"); private String searchCategory; private String searchFaq; private String disabledCategory; private String enabledCategory; @DataProvider(name = "Incorrect_Data_Cat") public Object[][] createData6() { return category_dp.GenerateFullCheck(); } @DataProvider(name = "Valid_Data_Cat") public Object[][] createData5() { return category_dp.GenerateTreeRecord("existingValue"); } @DataProvider(name = "Edit_Data_Cat") public Object[][] createData7() { return category_dp.GenerateTreeRecord("editValue"); } @DataProvider(name = "CleanUp_Data_Cat") public Object[][] createData8() { return category_dp.GenerateTreeRecord("editValue"); } @DataProvider(name = "Incorrect_Data") public Object[][] createData2() { return dp.GenerateFullCheck(); } @DataProvider(name = "Valid_Data") public Object[][] createData1() { return dp.GenerateTreeRecord("existingValue"); } @DataProvider(name = "Edit_Data") public Object[][] createData3() { return dp.GenerateTreeRecord("editValue"); } @DataProvider(name = "CleanUp_Data") public Object[][] createData4() { return 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_Cat", groups="FAQ_Cat") public void TestValidFaqCategoryItem(Map> fields){ driver.get(settings.http + settings.adminUrl + moduleCatPath); BackEnd_FaqCategoryPage be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); BackEnd_FaqCategoryAddPage be_faqCategoryAddPage = be_faqCategoryPage.openAddNewForm(); be_faqCategoryPage = be_faqCategoryAddPage.addNew(fields); assertTrue(be_faqCategoryPage.getAlertInfo().contains(addedCategoryAlert), "Expected '"+addedCategoryAlert+"' to appear on page, but found: '"+be_faqCategoryPage.getAlertInfo()+"'"); searchCategory = fields.get("title").get("value"); be_faqCategoryPage.doSearch(searchCategory); Map FirstRecordData = be_faqCategoryPage.getFirstRecordDataFromTable(); assertTrue(fields.get("title").get("value").equals(FirstRecordData.get("title")), "Expected Title to be '"+fields.get("title").get("value")+"', but found '"+FirstRecordData.get("title")+"'"); BackEnd_FaqCategoryEditPage be_faqCategoryEditPage = be_faqCategoryPage.editFirstRecordFromTable(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_faqCategoryEditPage.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_faqCategoryEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_faqCategoryEditPage.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_Cat", dependsOnMethods="TestEditFaqCategoryItem", priority=1, groups="FAQ_Cat", enabled=true) public void TestEmptyFaqCategoryFrontEnd(Map> fields){ driver.get(settings.http + settings.adminUrl + moduleCatPath); BackEnd_FaqCategoryPage be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); be_faqCategoryPage.doSearch(searchCategory); Map controls = be_faqCategoryPage.getFirstRecordControlsFromTable(); Map> params = getQueryParams(controls.get("edit").getAttribute("href")); String itemId = params.get("id").get(0); driver.get(settings.http + settings.siteUrl + moduleFrontEndPath +"/"+itemId); assertTrue(driver.findElement(By.tagName("body")).getText().contains("404 - Not Found"), "This is not 404 page"); } @Test(dataProvider = "Incorrect_Data_Cat", dependsOnMethods="TestValidFaqCategoryItem", priority=2, groups="FAQ_Cat", enabled=true) public void TestIncorrectFaqCategoryItem(Map> fieldsData, Map> expectedErrors) throws InterruptedException{ driver.get(settings.http + settings.adminUrl + moduleCatPath); BackEnd_FaqCategoryPage be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); BackEnd_FaqCategoryAddPage be_faqCategoryAddPage = be_faqCategoryPage.openAddNewForm(); be_faqCategoryAddPage = be_faqCategoryAddPage.submitIncorrectData(fieldsData); Map>realFormErrors = be_faqCategoryAddPage.getFieldsAlerts(); compareFormErrors(realFormErrors, expectedErrors); } @Test(dataProvider = "Edit_Data_Cat", dependsOnMethods="TestValidFaqCategoryItem", priority=3, groups="FAQ_Cat", enabled=true) public void TestEditFaqCategoryItem(Map> fields){ driver.get(settings.http + settings.adminUrl + moduleCatPath); BackEnd_FaqCategoryPage be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); be_faqCategoryPage.doSearch(searchCategory); BackEnd_FaqCategoryEditPage be_faqCategoryEditPage = be_faqCategoryPage.editFirstRecordFromTable(); be_faqCategoryPage = be_faqCategoryEditPage.editRecord(fields); assertTrue(be_faqCategoryPage.getAlertInfo().contains(updatedCategoryAlert), "Expected '"+updatedCategoryAlert+"' to appear on page, but found: '"+be_faqCategoryPage.getAlertInfo()+"'"); if(fields.get("enabled").get("value").equals("true")){ enabledCategory = fields.get("title").get("value"); } else{ disabledCategory = fields.get("title").get("value"); } searchCategory = fields.get("title").get("value"); be_faqCategoryPage.doSearch(searchCategory); Map FirstRecordData = be_faqCategoryPage.getFirstRecordDataFromTable(); assertTrue(fields.get("title").get("value").equals(FirstRecordData.get("title")), "Expected Name to be '"+fields.get("title").get("value")+"', but found '"+FirstRecordData.get("title")+"'"); be_faqCategoryEditPage = be_faqCategoryPage.editFirstRecordFromTable(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_faqCategoryEditPage.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_faqCategoryEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_faqCategoryEditPage.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_Cat", dependsOnMethods="TestEditFaqCategoryItem", priority=3, groups="FAQ_Cat", enabled=true) public void TestSecondValidFaqCategoryItem(Map> fields){ driver.get(settings.http + settings.adminUrl + moduleCatPath); BackEnd_FaqCategoryPage be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); BackEnd_FaqCategoryAddPage be_faqCategoryAddPage = be_faqCategoryPage.openAddNewForm(); be_faqCategoryPage = be_faqCategoryAddPage.addNew(fields); if(fields.get("enabled").get("value").equals("true")){ enabledCategory = fields.get("title").get("value"); } else{ disabledCategory = fields.get("title").get("value"); } assertTrue(be_faqCategoryPage.getAlertInfo().contains(addedCategoryAlert), "Expected '"+addedCategoryAlert+"' to appear on page, but found: '"+be_faqCategoryPage.getAlertInfo()+"'"); searchCategory = fields.get("title").get("value"); be_faqCategoryPage.doSearch(searchCategory); Map FirstRecordData = be_faqCategoryPage.getFirstRecordDataFromTable(); assertTrue(fields.get("title").get("value").equals(FirstRecordData.get("title")), "Expected Title to be '"+fields.get("title").get("value")+"', but found '"+FirstRecordData.get("title")+"'"); BackEnd_FaqCategoryEditPage be_faqCategoryEditPage = be_faqCategoryPage.editFirstRecordFromTable(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_faqCategoryEditPage.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_faqCategoryEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_faqCategoryEditPage.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_Cat", dependsOnMethods="TestEditFaqCategoryItem", priority=5, groups="FAQ_Cat", enabled=true) public void TestIncorrectEditFaqCategoryItem(Map> fieldsData, Map> expectedErrors) throws InterruptedException{ driver.get(settings.http + settings.adminUrl + moduleCatPath); BackEnd_FaqCategoryPage be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); be_faqCategoryPage.doSearch(searchCategory); BackEnd_FaqCategoryEditPage be_faqCategoryEditPage = be_faqCategoryPage.editFirstRecordFromTable(); Map> clearData = category_dp.GenerateClearForm(); be_faqCategoryEditPage.clearForm(clearData); be_faqCategoryEditPage = be_faqCategoryEditPage.submitIncorrectData(fieldsData); Map>realFormErrors = be_faqCategoryEditPage.getFieldsAlerts(); compareFormErrors(realFormErrors, expectedErrors); } @Test(dataProvider = "Valid_Data", dependsOnGroups="FAQ_Cat") public void TestValidFaqItem(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_FaqPage be_faqPage = new BackEnd_FaqPage(driver); BackEnd_FaqAddPage be_faqAddPage = be_faqPage.openAddNewForm(); be_faqPage = be_faqAddPage.addNew(fields); assertTrue(be_faqPage.getAlertInfo().contains(addedAlert), "Expected '"+addedAlert+"' to appear on page, but found: '"+be_faqPage.getAlertInfo()+"'"); searchFaq = fields.get("question").get("value"); be_faqPage.doSearch(fields.get("question").get("value"), fields.get("categoryId").get("value")); Map FirstRecordData = be_faqPage.getFirstRecordDataFromTable(); if(fields.get("categoryId").get("value").isEmpty()){ assertTrue("No Category".equals(FirstRecordData.get("category")), "Expected Category to be 'No Category', but found '"+FirstRecordData.get("category")+"'"); } else{ assertTrue(fields.get("categoryId").get("value").equals(FirstRecordData.get("category")), "Expected Category to be '"+fields.get("categoryId").get("value")+"', but found '"+FirstRecordData.get("category")+"'"); } assertTrue(fields.get("question").get("value").equals(FirstRecordData.get("question")), "Expected Title to be '"+fields.get("question").get("value")+"', but found '"+FirstRecordData.get("question")+"'"); BackEnd_FaqEditPage be_faqEditPage = be_faqPage.editFirstRecordFromTable(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_faqEditPage.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_faqEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_faqEditPage.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="TestValidFaqItem", priority=1) public void TestFaqFrontEnd(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_FaqPage be_faqPage = new BackEnd_FaqPage(driver); be_faqPage.doSearch(fields.get("question").get("value"), fields.get("categoryId").get("value")); BackEnd_FaqEditPage be_faqEditPage = be_faqPage.editFirstRecordFromTable(); String categoryId = be_faqEditPage.getSelectedCategoryId(); driver.get(settings.http + settings.siteUrl + moduleFrontEndPath +"/"+categoryId); FrontEnd_FaqPage fe_faqPage = new FrontEnd_FaqPage(driver); for(Entry> field : fields.entrySet()){ if(fe_faqPage.getFrontEndValue(field.getKey())!=null){ switch (field.getKey()) { case "categoryId":{ assertTrue(fe_faqPage.getFrontEndValue(field.getKey()).contains(field.getValue().get("value")), "Value for '"+field.getKey()+"' did not match with Front End"); } case "question":{ assertTrue(fe_faqPage.getFrontEndValue(field.getKey()).contains(field.getValue().get("value")), "Value for '"+field.getKey()+"' did not match with Front End"); } case "answer":{ assertTrue(fe_faqPage.getFrontEndValue(field.getKey()).contains(field.getValue().get("value")), "Value for '"+field.getKey()+"' did not match with Front End"); } break; default:{ assertEquals(fe_faqPage.getFrontEndValue(field.getKey()), field.getValue().get("value"), "Value for '"+field.getKey()+"' did not match with Front End"); } } } } } @Test(dependsOnMethods="TestValidFaqItem", priority=2) public void TestReorderFaqCategories(){ driver.get(settings.http + settings.adminUrl + moduleCatPath); BackEnd_FaqCategoryPage be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); ListtitleOrder = be_faqCategoryPage.getTableTitlesByOrder(); BackEnd_FaqCategoryReorderPage be_faqCategoryReorderPage = be_faqCategoryPage.openReorderPage(); String firstTitle = titleOrder.get(0); be_faqCategoryPage = be_faqCategoryReorderPage.moveElementToBottom(firstTitle); assertTrue(be_faqCategoryPage.getAlertInfo().contains(reorderedCategoryAlert), "Expected '"+reorderedCategoryAlert+"' to appear on page, but found: '"+be_faqCategoryPage.getAlertInfo()+"'"); titleOrder = be_faqCategoryPage.getTableTitlesByOrder(); assertEquals(titleOrder.get(titleOrder.size() - 1), firstTitle); driver.get(settings.http + settings.siteUrl + moduleFrontEndPath); FrontEnd_FaqPage fe_faqPage = new FrontEnd_FaqPage(driver); List orderCategoriesFrontEnd = fe_faqPage.getOrderCategories(); assertEquals(orderCategoriesFrontEnd.get(orderCategoriesFrontEnd.size() - 1), firstTitle); driver.get(settings.http + settings.adminUrl + moduleCatPath); be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); titleOrder = be_faqCategoryPage.getTableTitlesByOrder(); be_faqCategoryReorderPage = be_faqCategoryPage.openReorderPage(); String lastTitle = titleOrder.get(titleOrder.size() - 1); be_faqCategoryPage = be_faqCategoryReorderPage.moveElementToTop(lastTitle); assertTrue(be_faqCategoryPage.getAlertInfo().contains(reorderedCategoryAlert), "Expected '"+reorderedCategoryAlert+"' to appear on page, but found: '"+be_faqCategoryPage.getAlertInfo()+"'"); titleOrder = be_faqCategoryPage.getTableTitlesByOrder(); assertEquals(titleOrder.get(0), lastTitle); driver.get(settings.http + settings.siteUrl + moduleFrontEndPath); fe_faqPage = new FrontEnd_FaqPage(driver); orderCategoriesFrontEnd = fe_faqPage.getOrderCategories(); assertEquals(orderCategoriesFrontEnd.get(0), lastTitle); } @Test(dataProvider = "Incorrect_Data", dependsOnMethods="TestValidFaqItem", priority=3) public void TestIncorrectFaqItem(Map> fieldsData, Map> expectedErrors) throws InterruptedException{ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_FaqPage be_faqPage = new BackEnd_FaqPage(driver); BackEnd_FaqAddPage be_faqAddPage = be_faqPage.openAddNewForm(); be_faqAddPage = be_faqAddPage.submitIncorrectData(fieldsData); Map>realFormErrors = be_faqAddPage.getFieldsAlerts(); compareFormErrors(realFormErrors, expectedErrors); } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestReorderFaqCategories", priority=4) public void TestEditFaqItem(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_FaqPage be_faqPage = new BackEnd_FaqPage(driver); be_faqPage.doSearch(searchFaq, searchCategory); BackEnd_FaqEditPage be_faqEditPage = be_faqPage.editFirstRecordFromTable(); be_faqPage = be_faqEditPage.editRecord(fields); assertTrue(be_faqPage.getAlertInfo().contains(updatedAlert), "Expected '"+updatedAlert+"' to appear on page, but found: '"+be_faqPage.getAlertInfo()+"'"); searchFaq = fields.get("question").get("value"); searchCategory = fields.get("categoryId").get("value"); be_faqPage.doSearch(fields.get("question").get("value"), fields.get("categoryId").get("value")); Map FirstRecordData = be_faqPage.getFirstRecordDataFromTable(); //No Category if(fields.get("categoryId").get("value").isEmpty()){ assertTrue("No Category".equals(FirstRecordData.get("category")), "Expected Category to be 'No Category', but found '"+FirstRecordData.get("category")+"'"); } else{ assertTrue(fields.get("categoryId").get("value").equals(FirstRecordData.get("category")), "Expected Category to be '"+fields.get("categoryId").get("value")+"', but found '"+FirstRecordData.get("category")+"'"); } assertTrue(fields.get("question").get("value").equals(FirstRecordData.get("question")), "Expected Title to be '"+fields.get("question").get("value")+"', but found '"+FirstRecordData.get("question")+"'"); be_faqEditPage = be_faqPage.editFirstRecordFromTable(); for(Entry> field : fields.entrySet()){ switch (field.getValue().get("type")) { case "fck-editor": { assertTrue(be_faqEditPage.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_faqEditPage.getFormFieldValue(field.getKey(), field.getValue().get("type")).contains(fileNameWithOutExt), "File for "+field.getKey()+" doesn't match"); } break; default: assertEquals(be_faqEditPage.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="TestEditFaqItem", priority=5) public void TestIncorrectEditFaqItem(Map> fieldsData, Map> expectedErrors) throws InterruptedException{ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_FaqPage be_faqPage = new BackEnd_FaqPage(driver); BackEnd_FaqEditPage be_faqEditPage = be_faqPage.editFirstRecordFromTable(); Map> clearData = dp.GenerateClearForm(); be_faqEditPage.clearForm(clearData); be_faqEditPage = be_faqEditPage.submitIncorrectData(fieldsData); Map>realFormErrors = be_faqEditPage.getFieldsAlerts(); compareFormErrors(realFormErrors, expectedErrors); } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestIncorrectEditFaqItem", priority=6) public void TestDisabledFaqEnabledCategoryFrontEnd(Map> fields){ if(!fields.get("enabled").get("value").equals("true")){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_FaqPage be_faqPage = new BackEnd_FaqPage(driver); be_faqPage.doSearch(fields.get("question").get("value"), fields.get("categoryId").get("value")); BackEnd_FaqEditPage be_faqEditPage = be_faqPage.editFirstRecordFromTable(); fields.get("categoryId").put("value", enabledCategory); be_faqPage = be_faqEditPage.editRecord(fields); be_faqPage.doSearch(fields.get("question").get("value"), enabledCategory); be_faqEditPage = be_faqPage.editFirstRecordFromTable(); String categoryId = be_faqEditPage.getSelectedCategoryId(); driver.get(settings.http + settings.siteUrl + moduleFrontEndPath +"/"+categoryId); waitForPageLoaded(); assertTrue(driver.findElement(By.tagName("body")).getText().contains("404 - Not Found"), "This is not 404 page"); } else{ throw new SkipException("News item was not disabled during editing"); } } @Test(dataProvider = "Edit_Data", dependsOnMethods="TestDisabledFaqEnabledCategoryFrontEnd", priority=7) public void TestEnabledFaqDisabledCategoryFrontEnd(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_FaqPage be_faqPage = new BackEnd_FaqPage(driver); be_faqPage.doSearch(fields.get("question").get("value"), enabledCategory); BackEnd_FaqEditPage be_faqEditPage = be_faqPage.editFirstRecordFromTable(); fields.get("categoryId").put("value", disabledCategory); fields.get("enabled").put("value", "true"); be_faqPage = be_faqEditPage.editRecord(fields); be_faqPage.doSearch(fields.get("question").get("value"), disabledCategory); be_faqEditPage = be_faqPage.editFirstRecordFromTable(); String categoryId = be_faqEditPage.getSelectedCategoryId(); driver.get(settings.http + settings.siteUrl + moduleFrontEndPath +"/"+categoryId); waitForPageLoaded(); assertTrue(driver.findElement(By.tagName("body")).getText().contains("404 - Not Found"), "This is not 404 page"); } @Test(dataProvider = "CleanUp_Data", dependsOnMethods="TestEnabledFaqDisabledCategoryFrontEnd", priority=8) public void cleanUpFaq(Map> fields){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_FaqPage be_faqPage = new BackEnd_FaqPage(driver); be_faqPage.doSearch(fields.get("question").get("value"), ""); try { be_faqPage.deleteFirstRecordFromTable(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } assertTrue(be_faqPage.getAlertInfo().contains(deletedAlert), "Expected '"+deletedAlert+"' to appear on page, but found: '"+be_faqPage.getAlertInfo()+"'"); driver.get(settings.http + settings.adminUrl + moduleCatPath); BackEnd_FaqCategoryPage be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); //searchCategory = fields.get("question").get("value"); be_faqCategoryPage.doSearch(enabledCategory); try { be_faqCategoryPage.deleteFirstRecordFromTable(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } assertTrue(be_faqCategoryPage.getAlertInfo().contains(deletedCategoryAlert), "Expected '"+deletedCategoryAlert+"' to appear on page, but found: '"+be_faqCategoryPage.getAlertInfo()+"'"); driver.get(settings.http + settings.adminUrl + moduleCatPath); be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); //searchCategory = fields.get("question").get("value"); be_faqCategoryPage.doSearch(disabledCategory); try { be_faqCategoryPage.deleteFirstRecordFromTable(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } assertTrue(be_faqCategoryPage.getAlertInfo().contains(deletedCategoryAlert), "Expected '"+deletedCategoryAlert+"' to appear on page, but found: '"+be_faqCategoryPage.getAlertInfo()+"'"); } @Test(priority=7, description = "") public void testCancelButton(){ driver.get(settings.http + settings.adminUrl + modulePath); BackEnd_FaqPage be_faqPage = new BackEnd_FaqPage(driver); BackEnd_FaqAddPage be_faqAddPage = be_faqPage.openAddNewForm(); be_faqPage = be_faqAddPage.clickCancel(); //be_faqPage.doSearch(searchText); driver.findElement(By.id("btnCancel")).click(); waitForPageLoaded(); be_faqPage = new BackEnd_FaqPage(driver); driver.get(settings.http + settings.adminUrl + moduleCatPath); BackEnd_FaqCategoryPage be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); BackEnd_FaqCategoryAddPage be_faqCategoryAddPage = be_faqCategoryPage.openAddNewForm(); be_faqCategoryPage = be_faqCategoryAddPage.clickCancel(); //be_faqPage.doSearch(searchText); driver.findElement(By.id("btnCancel")).click(); be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); BackEnd_FaqCategoryReorderPage be_faqCategoryReorderPage = be_faqCategoryPage.openReorderPage(); be_faqCategoryPage = be_faqCategoryReorderPage.clickCancel(); driver.findElement(By.id("btnCancel")).click(); waitForPageLoaded(); be_faqCategoryPage = new BackEnd_FaqCategoryPage(driver); } @AfterClass public void tearDown(){ driver.quit(); //driver.close(); } }