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/Admin.java b/src/main/java/com/orasi/bluesource/Admin.java new file mode 100644 index 0000000..5c064c0 --- /dev/null +++ b/src/main/java/com/orasi/bluesource/Admin.java @@ -0,0 +1,100 @@ +package com.orasi.bluesource; + +import org.openqa.selenium.support.FindBy; + +import com.orasi.web.OrasiDriver; +import com.orasi.web.webelements.Button; +import com.orasi.web.webelements.Label; +import com.orasi.web.webelements.Textbox; +import com.orasi.web.webelements.impl.internal.ElementFactory; + +public class Admin { +private OrasiDriver driver = null; + + /**Page Elements**/ + @FindBy(xpath = "//a[contains(text(),'Add New Holiday')]") private Button btnAddNewHoliday; + @FindBy(xpath = "//*[@id='content']/table/tbody/tr/td[1]") private Label lblFirstHolidayName; + @FindBy(xpath = "//*[@id='content']/table/tbody/tr/td[2]") private Label lblFirstHolidayDate; + @FindBy(xpath = "//*[@id='holiday_name']") private Textbox txtHolidayName; + @FindBy(xpath = "//*[@id='holiday_date']") private Textbox txtHolidayDate; + @FindBy(xpath = "//input[@value='Create Holiday']") private Button btnCreateHoliday; + @FindBy(xpath = "//*[@id='notification-area']/div") private Label lblFailureMessage; + + /**Constructor**/ + public Admin(OrasiDriver driver){ + this.driver = driver; + ElementFactory.initElements(driver, this); + } + + /**Page Interactions**/ + + public void clickAddNewHoliday() { + btnAddNewHoliday.syncVisible(2,true); + btnAddNewHoliday.click(); + } + + /** + * Verifies the Add New Holiday button is onscreen + * @return - True if button is onscreen + */ + public boolean verifyAddNewHoliday() { + return btnAddNewHoliday.syncVisible(2,true); + } + + /** + * Retrives the first holiday name from the table + * @return - String with Holiday Name + */ + public String getFirstHolidayName() { + return lblFirstHolidayName.getText(); + } + + /** + * Gets the first holiday listed's end date in form "YYYY-MM-DD" + * @return - String of the date + */ + public String getFirstHolidayDate() { + return lblFirstHolidayDate.getText(); + } + + /** + * Verifies the Textbox for Holiday Name on the new Holiday screen appears + * @return - True if exists on screen + */ + public boolean verifyNewHolidayName() { + return txtHolidayName.syncVisible(2,true); + } + + /** + * Populates the New Holiday Name field with whats passed + * @param holidayName - Name of the new holiday + */ + public void populateHolidayname(String holidayName) { + txtHolidayName.syncVisible(2,true); + txtHolidayName.set(holidayName); + } + + /** + * Populates the New Holiday date field in form "MMDDYYYY" + * @param holidayDate + */ + public void populateHolidayDate(String holidayDate) { + String parsedDate = holidayDate.substring(5,7)+holidayDate.substring(8,10)+holidayDate.substring(0, 4); + txtHolidayDate.sendKeys(parsedDate); + } + + public void clickCreateHoliday() { + btnCreateHoliday.syncVisible(2,true); + btnCreateHoliday.click(); + } + + /** + * Verifies the notification message onscreen matches what is passed + * @param failMessage - Full Error message + * @return - True if what is shown onscreen matches what's passed + */ + public boolean verifyFailureMessage(String failMessage) { + System.out.println(lblFailureMessage.getText().substring(2)); + return lblFailureMessage.getText().substring(2).equalsIgnoreCase(failMessage); + } +} diff --git a/src/main/java/com/orasi/bluesource/EmployeePage.java b/src/main/java/com/orasi/bluesource/EmployeePage.java index 2cf3f9b..3ac1f65 100644 --- a/src/main/java/com/orasi/bluesource/EmployeePage.java +++ b/src/main/java/com/orasi/bluesource/EmployeePage.java @@ -7,6 +7,7 @@ import com.orasi.web.webelements.Checkbox; import com.orasi.web.webelements.Element; import com.orasi.web.webelements.Label; +import com.orasi.web.webelements.Listbox; import com.orasi.web.webelements.Textbox; import com.orasi.web.webelements.Webtable; import com.orasi.web.webelements.impl.internal.ElementFactory; @@ -17,9 +18,9 @@ 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(partialLinkText = "Deactivate Employee") Button btnDeactivateEmployee; + @FindBy(partialLinkText = "Deactivate") Button btnDeactivate; /**Constructor**/ public EmployeePage(OrasiDriver driver){ @@ -59,15 +60,18 @@ 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(){ + btnDeactivateEmployee.syncVisible(2, true); btnDeactivate.click(); } diff --git a/src/main/java/com/orasi/bluesource/Employees.java b/src/main/java/com/orasi/bluesource/Employees.java index 4f7c74d..f53f210 100644 --- a/src/main/java/com/orasi/bluesource/Employees.java +++ b/src/main/java/com/orasi/bluesource/Employees.java @@ -55,8 +55,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 +311,7 @@ public boolean checkAccountPermissionOption(String strOption) { catch (OptionNotInListboxException e){ return false; } - + } - + } \ 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..0f58451 100644 --- a/src/main/java/com/orasi/bluesource/Header.java +++ b/src/main/java/com/orasi/bluesource/Header.java @@ -18,8 +18,8 @@ public class Header { @FindBy(xpath = "//li[contains(.,'Employees')]/a") private Link lnkEmployees; @FindBy(xpath = "//a[contains(text(),'Project')]") private Link lnkProjemployees; @FindBy(xpath = "//a[contains(text(),'Project')]//..//..//..//following-sibling::a") private Link lnkEmployeeSelector; - @FindBy(linkText = "Admin") private Link lnkAdmin; - @FindBy(linkText = "Timesheet Locks") private Link lnkTimesheetLocks; + @FindBy(xpath = "/html/body/header/div/nav/ul/li[2]/a") private Link lnkAdminDropdown; + @FindBy(xpath = "//a[contains(text(),'Company Holidays')]") private Link lnkCompanyHolidays; /**Constructor**/ public Header(OrasiDriver driver){ @@ -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() { @@ -83,10 +86,9 @@ public void navigateLogout() { lnkLogout.click(); } - public void navigateTimesheetLocks() { - MessageCenter messageCenter = new MessageCenter(driver); - messageCenter.closeMessageCenter(); - lnkAdmin.click(); - lnkTimesheetLocks.click(); + public void navigateCompanyHolidays() { + lnkAdminDropdown.click(); + lnkCompanyHolidays.syncVisible(2,true); + lnkCompanyHolidays.click(); } } \ No newline at end of file diff --git a/src/test/java/com/bluesource/CompanyAdminAdminCompanyHolidaysDuplicateError.java b/src/test/java/com/bluesource/CompanyAdminAdminCompanyHolidaysDuplicateError.java new file mode 100644 index 0000000..d3e52e7 --- /dev/null +++ b/src/test/java/com/bluesource/CompanyAdminAdminCompanyHolidaysDuplicateError.java @@ -0,0 +1,76 @@ +/** + * Tests Company Admin_Admin_Company Holidays_Duplicate_Error - Issue #748 + * Test attempts to create a Holiday with the same Name and Date as an + * already existing holiday, then verifies the duplicate holiday is + * not created and the proper error message is shown + * @author andrew.mcgrail + */ +package com.bluesource; + +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.Admin; +import com.orasi.bluesource.Header; +import com.orasi.bluesource.LoginPage; +import com.orasi.utils.TestReporter; +import com.orasi.web.WebBaseTest; + +public class CompanyAdminAdminCompanyHolidaysDuplicateError 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("CompanyAdminAdminCompanyHolidaysDuplicateError"); + } + + @AfterMethod + public void close(ITestContext testResults){ + endTest("TestAlert", testResults); + } + + @Test + public void testCompanyAdminAdminCompanyHolidaysDuplicateError() + { + String holidayName, holidayDate = null; + + LoginPage loginPage = new LoginPage(getDriver()); + Header header = new Header(getDriver()); + Admin adminPage = new Admin(getDriver()); + + // Step 1 Open the browser and navigate to "http://10.238.243.127". + // Step 2 Login as 'company.admin'. + loginPage.AdminLogin(); + // Step 3 Click on 'Admin' -> 'Company Holidays'. + header.navigateCompanyHolidays(); + TestReporter.assertTrue(adminPage.verifyAddNewHoliday(), "Successfully landed on Company Holidays page"); + // Step 4 Notate the name and date of an existing Holiday. + holidayName = adminPage.getFirstHolidayName(); + holidayDate = adminPage.getFirstHolidayDate(); + String failMessage = "Holiday "+holidayName+" failed to be created. [[\"Date has already been taken\"]]"; + // Step 5 Click the 'Add New Holiday' button. + adminPage.clickAddNewHoliday(); + TestReporter.assertTrue(adminPage.verifyNewHolidayName(), "Successfully landed on New Holiday page"); + // Step 6 Inside the 'Name' textbox, enter in the Name of an existing Holiday. + adminPage.populateHolidayname(holidayName); + // Step 7 Select the Date of the existing Holiday inside the 'Date' field. + adminPage.populateHolidayDate(holidayDate); + // Step 8 Click the 'Create Holiday' button. + adminPage.clickCreateHoliday(); + // Step 9 Verify the Error Message displays on the page the user is currently displaying. + TestReporter.assertTrue(adminPage.verifyFailureMessage(failMessage), "Verified the Holiday couldn't be created and the error message is correct"); + } +} \ 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..5d45e74 100644 --- a/src/test/resources/sandbox.xml +++ b/src/test/resources/sandbox.xml @@ -13,7 +13,7 @@ - +