diff --git a/drivers/chromedriver.exe b/drivers/chromedriver.exe new file mode 100644 index 0000000..28a4067 Binary files /dev/null and b/drivers/chromedriver.exe differ diff --git a/src/main/java/com/orasi/bluesource/EmployeePage.java b/src/main/java/com/orasi/bluesource/EmployeePage.java index 2cf3f9b..7b47bb1 100644 --- a/src/main/java/com/orasi/bluesource/EmployeePage.java +++ b/src/main/java/com/orasi/bluesource/EmployeePage.java @@ -1,11 +1,13 @@ package com.orasi.bluesource; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebDriverException; +import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; import com.orasi.web.OrasiDriver; import com.orasi.web.webelements.Button; -import com.orasi.web.webelements.Checkbox; -import com.orasi.web.webelements.Element; import com.orasi.web.webelements.Label; import com.orasi.web.webelements.Textbox; import com.orasi.web.webelements.Webtable; @@ -17,9 +19,18 @@ public class EmployeePage { /**Page Elements**/ @FindBy(xpath = "//tr[1]//a[@class='glyphicon glyphicon-pencil']") Button btnEditFirstProject; @FindBy(xpath = "//div[@id='panel_body_1']//table") Webtable tblProjectInfo; - @FindBy(xpath = "//button[@data-target='#modal_1']") Button btnEditGeneral; - @FindBy(xpath = "//div//a[contains(text(),'Deactivate Employee')]") Button btnDeactivateEmployee; - @FindBy(xpath = "//div[@class='panel-heading']//a[contains(text(),'Deactivate')]") Button btnDeactivate; + @FindBy(xpath = "//*[@id=\'accordion\']/div/div[7]/button") Button btnEditGeneral; + @FindBy(xpath = "//*[@id='content']/h1") Label lblEmployeeNameHeader; + @FindBy(xpath = "//a[contains(text(),'Deactivate Employee')]") Button btnDeactivateEmployee; + @FindBy(xpath = "//a[contains(text(),'Deactivate')]") Button btnDeactivate; + @FindBy(xpath = "//*[@id=\"panel_body_1\"]/div/ul/li") Label lblDeactivateWarningMessage; + @FindBy(xpath = "//*[@id=\"select2-employee_manager_id-container\"]") Textbox txtEmployeeManager; + @FindBy(xpath = "//*[@id='panel_body_1']/div/ul[1]/li/div") Label lblDeactivateActiveWarnings; + @FindBy(xpath = "//*[@id='accordion']/div/div[5]/div[1]/a") Button btnManageTimeOff; + @FindBy(xpath = "//tr[@class='vacation-row']") Label lblFirstTimeOffOnTable; + @FindBy(xpath = "//td[contains(text(),'Status:')]/../td[2]") Label lblEmployeeStatus; + @FindBy(xpath = "//tr[@class='vacation-row']/td[3]/span") Label lblFirstTimeOffEndDate; + /**Constructor**/ public EmployeePage(OrasiDriver driver){ @@ -59,16 +70,145 @@ public boolean verifyStartDate(String strStartDate, String strProject) { } public void editGeneralInfo() { + btnEditGeneral.syncVisible(3, true); btnEditGeneral.click(); - } public void clickDeactivateEmployee() { + btnDeactivateEmployee.syncVisible(2, true); btnDeactivateEmployee.click(); } public void clickDeactivate(){ + btnDeactivate.syncVisible(2, true); btnDeactivate.click(); } + /** + * Checks that the employee page you are currently on is for the + * employee you pass + * @param fullName - Name of employee you wish to check for + * @return - True if the name on the page matchs the passed value + */ + public boolean verifyEmployeePage(String fullName) { + return lblEmployeeNameHeader.getText().equalsIgnoreCase(fullName); + } + + public boolean verifyDeactivateEmployeesButton() { + return btnDeactivateEmployee.syncVisible(2,true); + } + + public boolean verifyDeactivateButton() { + return btnDeactivate.syncVisible(2,true); + } + + public boolean verifyEmployeesLoseManagerMessage() { + return lblDeactivateWarningMessage.syncVisible(2,true); + } + + /** + * This method returns the name of the employee that will be + * left without a manager due to the deactivation message + * @return - The name of the employee + */ + public String getEmployeeLosingmanager() { + return lblDeactivateWarningMessage.getText().substring(0, lblDeactivateWarningMessage.getText().indexOf(" will have ")); + } + + /** + * This method checks if the employee page currently brought up + * has a manager listed + * @return - True if no manager listed + */ + public boolean verifyManagerIsEmpty() { + return txtEmployeeManager.getAttribute("title").isEmpty(); + } + + /** + * This method checks if the Deactivate Button is onscreen, + * but cannot be clicked due to a manual warning. + * @return - True if Deactivate Button is onscreen but not interactable + */ + public boolean verifyInactiveDeactivateButton() { + try{ + btnDeactivate.click(); + } + catch(WebDriverException e) { + // This shows the Button cannot be clicked, if it could it would no longer be visible. + } + return btnDeactivate.syncVisible(2,true); + } + + /** + * Checks if the error message from attempting to deactivate an employee + * correctly warns about subordinates. + * @return - True if the warning message matchs what it should + */ + public boolean verifyActiveDeactivateMessage() { + return lblDeactivateActiveWarnings.getText().substring(lblDeactivateActiveWarnings.getText().indexOf(' ', + lblDeactivateActiveWarnings.getText().indexOf(' ')+1)).equalsIgnoreCase(" must be reassigned to another manager."); + } + + /** + * This method verifies a message is displayed when the mouse hovers over + * the inactive deactivate button (due to manual warnings) + * @return - True if Deactivate button is onscreen but no interactable + */ + public boolean verifyDeactiveButtonMessage() { + Actions action = driver.actions(); + action.moveToElement(driver.findElement(By.xpath("//a[contains(text(),'Deactivate')]"))).build().perform(); + return driver.findLabel(By.xpath("//div[@class='tooltip fade top in']")).syncInFrame(2,true); + } + + /** + * Checks if the warning message displays the time off + * request that will be deleted. + * @return - True if the warning message is correct + */ + public boolean verifyEmployeesVacationDeactivation() { + boolean checker = false; + if(lblDeactivateWarningMessage.getText().contains(" from ") && lblDeactivateWarningMessage.getText().contains(" will be deleted.")) + checker=true; + return checker; + } + + public void clickManageTimeOff() { + btnManageTimeOff.syncVisible(2, true); + btnManageTimeOff.click(); + } + + /** + * Verifies there is no time off listed for the employee + * @return - True if no time off + */ + public boolean verifyNoTimeOff() { + boolean checker = false; + try { + lblFirstTimeOffOnTable.isDisplayed(); + } + catch(NoSuchElementException e) { + checker = true; + } + return checker; + } + + /** + * Checks for a specified status on the employee page + * (Active, Permanent, Contractor) + * @param status - String of the status to check for + * @return - True if the status matchs + */ + public boolean verifyEmployeeStatus(String status) { + return lblEmployeeStatus.getText().equalsIgnoreCase(status); + } + + /** + * Verifies the first time off listed for an employee has + * the correct (passed) end date listed + * @param endDate - In form "Month DD, YYYY" + * @return - True if the end date on the form matchs the passed + */ + public boolean verifyFirstTimeOffEndDate(String endDate) { + return lblFirstTimeOffEndDate.getText().equalsIgnoreCase(endDate); + } } \ No newline at end of file diff --git a/src/main/java/com/orasi/bluesource/Employees.java b/src/main/java/com/orasi/bluesource/Employees.java index 4f7c74d..4ca318e 100644 --- a/src/main/java/com/orasi/bluesource/Employees.java +++ b/src/main/java/com/orasi/bluesource/Employees.java @@ -3,7 +3,6 @@ import java.util.ResourceBundle; import org.openqa.selenium.By; -import org.openqa.selenium.Keys; import org.openqa.selenium.support.FindBy; import com.orasi.utils.Constants; @@ -11,10 +10,8 @@ import com.orasi.utils.TestReporter; import com.orasi.utils.dataHelpers.personFactory.Person; import com.orasi.web.OrasiDriver; -import com.orasi.web.PageLoaded; import com.orasi.web.exceptions.OptionNotInListboxException; import com.orasi.web.webelements.Button; -import com.orasi.web.webelements.Element; import com.orasi.web.webelements.Label; import com.orasi.web.webelements.Link; import com.orasi.web.webelements.Listbox; @@ -55,8 +52,10 @@ public void employeeSearch(String strSearch){ * @author Paul */ public void clickAddEmployee() { - btnAdd.syncEnabled(5,true); - btnAdd.click(); + btnAdd.syncVisible(2,true); + btnAdd.syncEnabled(2,true); + btnAdd.syncInFrame(2,true); + btnAdd.click(); } /** @@ -309,7 +308,14 @@ public boolean checkAccountPermissionOption(String strOption) { catch (OptionNotInListboxException e){ return false; } - + + } + /** + * This method checks if the employee searchbar is on the screen + * @return - True if the employee search bar is visible + * @author Andrew McGrail + */ + public boolean verifyEmployeeSearchExists() { + return txtEmployeeSearch.syncVisible(2,true); } - } \ No newline at end of file diff --git a/src/main/java/com/orasi/bluesource/Header.java b/src/main/java/com/orasi/bluesource/Header.java index 1c09b5a..a959902 100644 --- a/src/main/java/com/orasi/bluesource/Header.java +++ b/src/main/java/com/orasi/bluesource/Header.java @@ -64,9 +64,12 @@ else if (accountBool == false) * @author Paul */ public void navigateEmployees() { - MessageCenter messageCenter = new MessageCenter(driver); - messageCenter.closeMessageCenter(); - lnkEmployees.click(); + lnkEmployees.syncVisible(2,true); + // MessageCenter messageCenter = new MessageCenter(driver); + // messageCenter.closeMessageCenter(); + lnkEmployees.syncVisible(2,true); + lnkEmployees.syncInFrame(2,true); + lnkEmployees.click(); } public void navigateProjectEmployees() { diff --git a/src/test/java/com/bluesource/employees/DeactivateEmployeeActiveEmployees.java b/src/test/java/com/bluesource/employees/DeactivateEmployeeActiveEmployees.java new file mode 100644 index 0000000..6f70f07 --- /dev/null +++ b/src/test/java/com/bluesource/employees/DeactivateEmployeeActiveEmployees.java @@ -0,0 +1,85 @@ +/** + * Tests Deactivate Employee_Active Employees_Issue462 & 940 + * This test checks when a manager of an active subordinate is + * made inactive the system requires a manual change of manager + * and disallows the deactivation + * @author Andrew McGrail + */ + +package com.bluesource.employees; + +import com.orasi.utils.TestReporter; + +import org.testng.ITestContext; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import com.orasi.bluesource.EmployeePage; +import com.orasi.bluesource.Employees; +import com.orasi.bluesource.LoginPage; +import com.orasi.web.WebBaseTest; + +public class DeactivateEmployeeActiveEmployees extends WebBaseTest{ + + @BeforeMethod + @Parameters({ "runLocation", "browserUnderTest", "browserVersion", + "operatingSystem", "environment" }) + public void setup(@Optional String runLocation, String browserUnderTest, + String browserVersion, String operatingSystem, String environment) { + setApplicationUnderTest("BLUESOURCE"); + setBrowserUnderTest(browserUnderTest); + setBrowserVersion(browserVersion); + setOperatingSystem(operatingSystem); + setRunLocation(runLocation); + setEnvironment(environment); + setThreadDriver(true); + testStart("DeactivateEmployeeActiveEmployees"); + } + + @AfterMethod + public void close(ITestContext testResults){ + endTest("TestAlert", testResults); + } + + @Test + public void testDeactivateEmployeeActiveEmployees() + { + String firstName = "HasActive"; + String lastName = "Subordinates"; + String fullName = firstName+" "+lastName; + + LoginPage loginPage = new LoginPage(getDriver()); + Employees employees = new Employees(getDriver()); + EmployeePage employeePage = new EmployeePage(getDriver()); + + // Step 1 Preconditions: Identify or create a user that has active and inactive subordinates + // Employee: HasActive Subordinates + // Step 2 Open browser. + // Step 3 Navigate to http://10.238.242.236 + // Step 4 Enter a valid username of a user with one of the following roles: Company Admin, Department Admin, department Head, Upper management + // Step 5 Enter a valid password. + // Step 6 Click the Login button or press Enter. + loginPage.AdminLogin(); + // Step 7 Click an employee name. + employees.employeeSearch(fullName); + employees.selectEmployeeByName(firstName); + TestReporter.assertTrue(employeePage.verifyEmployeePage(fullName), "Successfully landed on "+fullName+"'s employee page"); + // Step 8 Click the Edit button in the General Info section. + employeePage.editGeneralInfo(); + TestReporter.assertTrue(employeePage.verifyDeactivateEmployeesButton(), fullName+"'s edit general modal has been brought up"); + // Step 9 Verify the Deactivate Employee button is displayed at the bottom of the window. + TestReporter.assertTrue(employeePage.verifyDeactivateEmployeesButton(), "The edit general modal has a Deactivate Employee Button"); + // Step 10 Click the Deactivate Employee button. + employeePage.clickDeactivateEmployee(); + TestReporter.assertTrue(employeePage.verifyDeactivateButton(), "The Deactivate Employee Button was pushed"); + // Step 11 Verify the Deactivate button is displayed and greyed out at the top right of the page. + TestReporter.assertTrue(employeePage.verifyInactiveDeactivateButton(), "The Deactivate Button is on the page and cannot be interacted with"); + // Step 12 Verify the text under 'Manual Actions' is displayed as a list of the employee's active subordinates: "(Employee) must be reassigned to another manager." + TestReporter.assertTrue(employeePage.verifyActiveDeactivateMessage(), "Verified the manual actions warning message"); + // Step 13 Hover over the 'Deactivate' button and verify there is a message you cannot deactivate employee until all manual actions are resolved. + TestReporter.assertTrue(employeePage.verifyDeactiveButtonMessage(), "The deactivate button displas a message when hovered over"); + } +} \ No newline at end of file diff --git a/src/test/java/com/bluesource/employees/DeactivateEmployeeCurrentVacationEndDate.java b/src/test/java/com/bluesource/employees/DeactivateEmployeeCurrentVacationEndDate.java new file mode 100644 index 0000000..9ad2815 --- /dev/null +++ b/src/test/java/com/bluesource/employees/DeactivateEmployeeCurrentVacationEndDate.java @@ -0,0 +1,101 @@ +/** + * Tests Deactivate Employee_Current Vacation End Date_Issue462 + * This test checks when an employee with a vacation scheduled + * during the time you attempt to deactivate, the system will + * warn about the time off and deactivating the employee will + * change the end date of their time off to the current date. + * @author Andrew McGrail + */ + +package com.bluesource.employees; + +import com.orasi.utils.TestReporter; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +import org.testng.ITestContext; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import com.orasi.bluesource.EmployeePage; +import com.orasi.bluesource.Employees; +import com.orasi.bluesource.LoginPage; +import com.orasi.web.WebBaseTest; + +public class DeactivateEmployeeCurrentVacationEndDate extends WebBaseTest{ + + @BeforeMethod + @Parameters({ "runLocation", "browserUnderTest", "browserVersion", + "operatingSystem", "environment" }) + public void setup(@Optional String runLocation, String browserUnderTest, + String browserVersion, String operatingSystem, String environment) { + setApplicationUnderTest("BLUESOURCE"); + setBrowserUnderTest(browserUnderTest); + setBrowserVersion(browserVersion); + setOperatingSystem(operatingSystem); + setRunLocation(runLocation); + setEnvironment(environment); + setThreadDriver(true); + testStart("DeactivateEmployeeCurrentVacationEndDate"); + } + + @AfterMethod + public void close(ITestContext testResults){ + endTest("TestAlert", testResults); + } + + @Test + public void testDeactivateEmployeeCurrentVacationEndDate() + { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MMMM dd, YYYY"); + LocalDate localDate = LocalDate.now(); + + String firstName = "Current"; + String lastName = "Vacation"; + String fullName = firstName+" "+lastName; + + LoginPage loginPage = new LoginPage(getDriver()); + Employees employees = new Employees(getDriver()); + EmployeePage employeePage = new EmployeePage(getDriver()); + + // Step 1 Preconditions: Identify or create a user that has a vacation request currently in progress. + // Employee: Current Vacation, Must be reset to Active + Having a current vacation request each test run. + // Step 2 Open browser. + // Step 3 Navigate to http://10.238.242.236 + // Step 4 Enter a valid username of a user with one of the following roles: Company Admin, Department Admin, department Head, Upper management + // Step 5 Enter a valid password. + // Step 6 Click the Login button or press Enter. + loginPage.AdminLogin(); + // Step 7 Click an employee name. + employees.employeeSearch(fullName); + employees.selectEmployeeByName(firstName); + TestReporter.assertTrue(employeePage.verifyEmployeePage(fullName), "Successfully landed on "+fullName+"'s employee page"); + // Step 8 Click the Edit button in the General Info section. + employeePage.editGeneralInfo(); + TestReporter.assertTrue(employeePage.verifyDeactivateEmployeesButton(), fullName+"'s edit general modal has been brought up"); + // Step 9 Verify the Deactivate Employee button is displayed at the bottom of the window. + TestReporter.assertTrue(employeePage.verifyDeactivateEmployeesButton(), "The edit general modal has a Deactivate Employee Button"); + // Step 10 Click the Deactivate Employee button. + employeePage.clickDeactivateEmployee(); + TestReporter.assertTrue(employeePage.verifyDeactivateButton(), "The Deactivate Employee Button was pushed"); + // Step 11 Verify the Deactivate button is displayed at the top right of the page. + TestReporter.assertTrue(employeePage.verifyDeactivateButton(), "The Deactivate Button is on the page"); + // Step 12 Click the Deactivate button. + employeePage.clickDeactivate(); + TestReporter.assertTrue(employees.verifyEmployeeSearchExists(), fullName+" has been deactivated"); + // Step 13 Click the OK button. + // No longer relevant + // Step 14 Click on the deactivated employee's name and verify that their status has changed to "Inactive" + employees.employeeSearch(fullName); + employees.selectEmployeeByName(firstName); + TestReporter.assertTrue(employeePage.verifyEmployeeStatus("Inactive"), "Successfully landed on "+fullName+"'s employee page and verified they are Inactive"); + // Step 15 Click the Edit button in the Time Off Info section. + employeePage.clickManageTimeOff(); + // Step 16 Verify that the current vacation request has an end date as the current date. + TestReporter.assertTrue(employeePage.verifyFirstTimeOffEndDate(dtf.format(localDate)), "Verified the Time Off now has an end date of "+dtf.format(localDate)); + } +} \ No newline at end of file diff --git a/src/test/java/com/bluesource/employees/DeactivateEmployeeFutureVacation.java b/src/test/java/com/bluesource/employees/DeactivateEmployeeFutureVacation.java new file mode 100644 index 0000000..6a78969 --- /dev/null +++ b/src/test/java/com/bluesource/employees/DeactivateEmployeeFutureVacation.java @@ -0,0 +1,96 @@ +/** + * Tests Deactivate Employee_Future Vacation_Issue462 + * This test checks when an employee with a vacation scheduled + * in the future is attempted to be deactivated the system will + * warn you that their vacation will be deleted, then actually deletes it + * @author Andrew McGrail + */ + +package com.bluesource.employees; + +import com.orasi.utils.TestReporter; + +import org.testng.ITestContext; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import com.orasi.bluesource.EmployeePage; +import com.orasi.bluesource.Employees; +import com.orasi.bluesource.LoginPage; +import com.orasi.web.WebBaseTest; + +public class DeactivateEmployeeFutureVacation extends WebBaseTest{ + + @BeforeMethod + @Parameters({ "runLocation", "browserUnderTest", "browserVersion", + "operatingSystem", "environment" }) + public void setup(@Optional String runLocation, String browserUnderTest, + String browserVersion, String operatingSystem, String environment) { + setApplicationUnderTest("BLUESOURCE"); + setBrowserUnderTest(browserUnderTest); + setBrowserVersion(browserVersion); + setOperatingSystem(operatingSystem); + setRunLocation(runLocation); + setEnvironment(environment); + setThreadDriver(true); + testStart("DeactivateEmployeeFutureVacation"); + } + + @AfterMethod + public void close(ITestContext testResults){ + endTest("TestAlert", testResults); + } + + @Test + public void testDeactivateEmployeeFutureVacation() + { + String firstName = "Future"; + String lastName = "Vacation"; + String fullName = firstName+" "+lastName; + + LoginPage loginPage = new LoginPage(getDriver()); + Employees employees = new Employees(getDriver()); + EmployeePage employeePage = new EmployeePage(getDriver()); + + // Step 1 Preconditions: Identify or create a user that has future vacation request approved. + // Employee: Future Vacation, Must be reset to Active + Having a future vacation request each test run. + // Step 2 Open browser. + // Step 3 Navigate to http://10.238.242.236 + // Step 4 Enter a valid username of a user with one of the following roles: Company Admin, Department Admin, department Head, Upper management + // Step 5 Enter a valid password. + // Step 6 Click the Login button or press Enter. + loginPage.AdminLogin(); + // Step 7 Click an employee name. + employees.employeeSearch(fullName); + employees.selectEmployeeByName(firstName); + TestReporter.assertTrue(employeePage.verifyEmployeePage(fullName), "Successfully landed on "+fullName+"'s employee page"); + // Step 8 Click the Edit button in the General Info section. + employeePage.editGeneralInfo(); + TestReporter.assertTrue(employeePage.verifyDeactivateEmployeesButton(), fullName+"'s edit general modal has been brought up"); + // Step 9 Verify the Deactivate Employee button is displayed at the bottom of the window. + TestReporter.assertTrue(employeePage.verifyDeactivateEmployeesButton(), "The edit general modal has a Deactivate Employee Button"); + // Step 10 Click the Deactivate Employee button. + employeePage.clickDeactivateEmployee(); + TestReporter.assertTrue(employeePage.verifyDeactivateButton(), "The Deactivate Employee Button was pushed"); + // Step 11 Verify the Deactivate button is displayed at the top right of the page. + TestReporter.assertTrue(employeePage.verifyDeactivateButton(), "The Deactivate Button is on the page"); + // Step 12 Verify that future vacation request are listed with the text: "Vacation from XX/XX/XXXX to XX/XX/XXXX will be deleted." + TestReporter.assertTrue(employeePage.verifyEmployeesVacationDeactivation(), "Warning message for deactivating "+fullName+" is displayed, showing vacation dates"); + // Step 13 Click the Deactivate button. + employeePage.clickDeactivate(); + TestReporter.assertTrue(employees.verifyEmployeeSearchExists(), fullName+" has been deactivated"); + // Step 14 Click the OK button. + // No longer relevant + // Step 15 Click on the deactivated employee's name and verify that their status has changed to "Inactive" + employees.employeeSearch(fullName); + employees.selectEmployeeByName(firstName); + TestReporter.assertTrue(employeePage.verifyEmployeePage(fullName), "Successfully landed on "+fullName+"'s employee page"); + // Step 16 Click the Edit button in the Time Off Info section. + employeePage.clickManageTimeOff(); + // Step 17 Verify that the future vacation request are not displayed. + TestReporter.assertTrue(employeePage.verifyNoTimeOff(), "Verified no vacation time is listed on "+fullName+"'s table."); + } +} \ No newline at end of file diff --git a/src/test/java/com/bluesource/employees/DeactivateEmployeeInactiveEmployees.java b/src/test/java/com/bluesource/employees/DeactivateEmployeeInactiveEmployees.java new file mode 100644 index 0000000..695f9a9 --- /dev/null +++ b/src/test/java/com/bluesource/employees/DeactivateEmployeeInactiveEmployees.java @@ -0,0 +1,94 @@ +/** + * Tests Deactivate Employee_Inactive Employees_Issue462 + * This test checks when a manager of an inactive subordinate is also + * made inactive the subordinate loses the manager. + * @author Andrew McGrail + */ + +package com.bluesource.employees; + +import com.orasi.utils.TestReporter; + +import org.testng.ITestContext; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import com.orasi.bluesource.EmployeePage; +import com.orasi.bluesource.Employees; +import com.orasi.bluesource.LoginPage; +import com.orasi.web.WebBaseTest; + +public class DeactivateEmployeeInactiveEmployees extends WebBaseTest{ + + @BeforeMethod + @Parameters({ "runLocation", "browserUnderTest", "browserVersion", + "operatingSystem", "environment" }) + public void setup(@Optional String runLocation, String browserUnderTest, + String browserVersion, String operatingSystem, String environment) { + setApplicationUnderTest("BLUESOURCE"); + setBrowserUnderTest(browserUnderTest); + setBrowserVersion(browserVersion); + setOperatingSystem(operatingSystem); + setRunLocation(runLocation); + setEnvironment(environment); + setThreadDriver(true); + testStart("DeactivateEmployeeInactiveEmployees"); + } + + @AfterMethod + public void close(ITestContext testResults){ + endTest("TestAlert", testResults); + } + + @Test + public void testDeactivateEmployeeInactiveEmployees() + { + String firstName = "HasInactive"; + String lastName = "Subordinates"; + String fullName = firstName+" "+lastName; + String subordinateName =null; + + LoginPage loginPage = new LoginPage(getDriver()); + Employees employees = new Employees(getDriver()); + EmployeePage employeePage = new EmployeePage(getDriver()); + + // Step 1 Preconditions: Identify or create a user that has inactive subordinates + // Employee: HasInactive Subordinates, Must be reset to Active + Having inactive subordinates each test run. + // Step 2 Open browser. + // Step 3 Navigate to http://10.238.242.236 + // Step 4 Enter a valid username of a user with one of the following roles: Company Admin, Department Admin, department Head, Upper management + // Step 5 Enter a valid password. + // Step 6 Click the Login button or press Enter. + loginPage.AdminLogin(); + // Step 7 Click an employee name. + employees.employeeSearch(fullName); + employees.selectEmployeeByName(firstName); + TestReporter.assertTrue(employeePage.verifyEmployeePage(fullName), "Successfully landed on "+fullName+"'s employee page"); + // Step 8 Click the Edit button in the General Info section. + employeePage.editGeneralInfo(); + TestReporter.assertTrue(employeePage.verifyDeactivateEmployeesButton(), fullName+"'s edit general modal has been brought up"); + // Step 9 Verify the Deactivate Employee button is displayed at the bottom of the window. + TestReporter.assertTrue(employeePage.verifyDeactivateEmployeesButton(), "The edit general modal has a Deactivate Employee Button"); + // Step 10 Click the Deactivate Employee button. + employeePage.clickDeactivateEmployee(); + TestReporter.assertTrue(employeePage.verifyDeactivateButton(), "The Deactivate Employee Button was pushed"); + // Step 11 Verify the Deactivate button is displayed at the top right of the page. + TestReporter.assertTrue(employeePage.verifyDeactivateButton(), "The Deactivate Button is on the page"); + // Step 12 "Verify the text under 'Automated Actions' is displayed as a list of the employee's inactive subordinates: ""(Employee) will have no manager.""" + TestReporter.assertTrue(employeePage.verifyEmployeesLoseManagerMessage(), "Warning message for deactivating "+fullName+" is displayed, showing subordinates"); + subordinateName = employeePage.getEmployeeLosingmanager(); + // Step 13 Click the Deactivate button + employeePage.clickDeactivate(); + TestReporter.assertTrue(employees.verifyEmployeeSearchExists(), fullName+" has been deactivated"); + // Step 14 Click the OK button. + // No longer relevant + // Step 15 Click on the name of the inactive subordinate previously listed. + employees.employeeSearch(subordinateName); + employees.selectEmployeeByName(subordinateName.substring(0, subordinateName.indexOf(' '))); + // Step 16 Verify that the employee has no manager listed. + TestReporter.assertTrue(employeePage.verifyManagerIsEmpty(), subordinateName+" has no manager selected"); + } +} \ No newline at end of file diff --git a/src/test/resources/drivers/chromedriver.exe b/src/test/resources/drivers/chromedriver.exe new file mode 100644 index 0000000..28a4067 Binary files /dev/null and b/src/test/resources/drivers/chromedriver.exe differ diff --git a/src/test/resources/sandbox.xml b/src/test/resources/sandbox.xml index d3793a8..56b33e6 100644 --- a/src/test/resources/sandbox.xml +++ b/src/test/resources/sandbox.xml @@ -13,7 +13,10 @@ - + + + +