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..3e32134 100644 --- a/src/main/java/com/orasi/bluesource/EmployeePage.java +++ b/src/main/java/com/orasi/bluesource/EmployeePage.java @@ -1,11 +1,12 @@ package com.orasi.bluesource; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +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 +18,22 @@ 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; + @FindBy(xpath = "//*[@id='accordion']/div/div[3]/h4/a") Button btnManageProjectInfo; + @FindBy(xpath = "//*[@id='content']/div[6]/table/tbody/tr[6]/td/a") Button btnAddTimesheetWeek3; + @FindBy(xpath = "//input[@value='Save']") Button btnSaveTimesheet; + @FindBy(xpath = "(//*[@id='employee_reported_times___date_hours_hours'])[1]") Textbox txtFirstDayOfTimesheet; + @FindBy(xpath = "//*[@id='comment']") Textbox txtCommentBox; + @FindBy(xpath = "//span[@class='select2-selection__arrow']") Button btnTimesheetTypeArrow; + @FindBy(xpath = "//input[@class='select2-search__field']") Textbox txtTimesheetType; + @FindBy(xpath = "//div[@class='btn btn-primary btn-xs submit-comment']") Button btnOkTimesheetComment; + @FindBy(xpath = "//*[@id='notification-area']/div") Label lblSaveCommentMessage; + @FindBy(xpath = "//span[@class='approval-section edit-icon glyphicon glyphicon-pencil']") Button btnEditTimesheetWeek; + @FindBy(xpath = "//a[@title='Delete']") Button btnDeleteTimesheetWeek; + @FindBy(xpath = "//*[@id='time_modal']/div/div") Label lblTimesheetModal; + @FindBy(xpath = "//span[@class='week_total_hours']") Label lblTimesheetTotalHours; /**Constructor**/ public EmployeePage(OrasiDriver driver){ @@ -59,16 +73,131 @@ 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(); } + public void clickManageProjectInfo() { + btnManageProjectInfo.syncVisible(2,true); + btnManageProjectInfo.click(); + } + + /** + * Verifies the Manage Project Info button is visible on the employee page + * @return - True if visible + */ + public boolean verifyManageProjectInfo() { + return btnManageProjectInfo.syncVisible(2,true); + } + + public void clickAddTimesheet3() { + btnAddTimesheetWeek3.syncVisible(2,true); + btnAddTimesheetWeek3.click(); + } + + /** + * Verifies the third week's Add Timesheet button is visible + * @return - True if visible + */ + public boolean verifyAddTimesheet3() { + return btnAddTimesheetWeek3.syncVisible(2,true); + } + + public void clickSaveTimesheet() { + btnSaveTimesheet.syncVisible(2,true); + btnSaveTimesheet.click(); + } + + /** + * Verifies the Save Timesheet button is onscreen + * @return - True if visible + */ + public boolean verifySaveTimesheet() { + return btnSaveTimesheet.syncVisible(2,true); + } + + /** + * Right clicks the first day of a timesheet onscreen + * @author andrew.mcgrail + */ + public void rightClickFirstDayOfTimesheet() { + Actions action = driver.actions(); + action.contextClick(driver.findElement(By.xpath("(//*[@id='employee_reported_times___date_hours_hours'])[1]"))).build().perform(); + } + + /** + * Chooses the "Bench" value for a non-billable timesheet onscreen + * @author andrew.mcgrail + */ + public void assignTimesheetType() { + lblTimesheetModal.syncVisible(2,true); + btnTimesheetTypeArrow.click(); + txtTimesheetType.sendKeys("Bench"+Keys.RETURN); + } + + public boolean verifyCommentBox() { + return txtCommentBox.syncVisible(2,true); + } + + /** + * Populates the first comment box on an employees weekly timesheet + * @param comment - The comment to populate the box with + * @author andrew.mcgrail + */ + public void populateCommentBox(String comment) { + txtCommentBox.sendKeys(comment); + btnOkTimesheetComment.click(); + } + + /** + * Verifies the comment box shows the passed value + * @param comment - Comment to be checked for + * @return - True if comments match + * @author andrew.mcgrail + */ + public boolean verifyCommentBox(String comment) { + return txtCommentBox.getText().equalsIgnoreCase(comment); + } + + /** + * Verifies the message for successfully saving a timesheet + * @return - True if the save timesheet message is displayed + * @author andrew.mcgrail + */ + public boolean verifySaveTimesheetMessage() { + return lblSaveCommentMessage.getText().substring(2,52).equalsIgnoreCase("Reported time for this week was saved successfully"); + } + + public void clickEditTimesheet() { + btnEditTimesheetWeek.syncVisible(2,true); + btnEditTimesheetWeek.click(); + } + + /** + * Checks that the passed value is equal to the total hours of the + * the timesheet currently onscreen + * @return - True if both times match + * @param hours - A String of the hours you want e.g. "0" + * @author andrew.mcgrail + */ + public boolean verifyTimesheetTotalHours(String hours) { + return lblTimesheetTotalHours.getText().equalsIgnoreCase(hours); + } + + public void clickDeleteTimesheet() { + btnDeleteTimesheetWeek.syncEnabled(2,true); + lblTimesheetModal.syncHidden(2,true); + btnDeleteTimesheetWeek.click(); + } } \ 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..1e99a6a 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,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..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/EmployeesTimesheetCommentsBlank.java b/src/test/java/com/bluesource/employees/EmployeesTimesheetCommentsBlank.java new file mode 100644 index 0000000..a25839b --- /dev/null +++ b/src/test/java/com/bluesource/employees/EmployeesTimesheetCommentsBlank.java @@ -0,0 +1,92 @@ +/** + * Tests Employees_Timesheet_CommentsBlank_Issue #613 + * Test checks that a department head can add comments to + * an employees timesheet without adding hours, and the + * comment will show up along with a 0 hour timesheet + * @author Andrew McGrail + */ + +package com.bluesource.employees; + +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.utils.TestReporter; +import com.orasi.web.WebBaseTest; + +public class EmployeesTimesheetCommentsBlank 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("EmployeesTimesheetCommentsBlank"); + } + + @AfterMethod + public void close(ITestContext testResults){ + endTest("TestAlert", testResults); + } + + @Test + public void testEmployeesTimesheetCommentsBlank() + { + String firstName = "Issue"; + String lastName = "613"; + String fullName = firstName+" "+lastName; + String comment = "This is a cool comment"; + + LoginPage loginPage = new LoginPage(getDriver()); + Employees employees = new Employees(getDriver()); + EmployeePage employeePage = new EmployeePage(getDriver()); + + // Step 1 Open a browser + // Step 2 Navigate to http://10.238.242.236 + // Step 3 Enter the username of a departmenthead in the username field and a password in the password field. Then click the login button. + loginPage.AdminLogin(); + // Step 4 Click the first name of an Employee in the Employee table. + employees.employeeSearch(fullName); + employees.selectEmployeeByName(firstName); + TestReporter.assertTrue(employeePage.verifyManageProjectInfo(), "Successfully landed on "+fullName+"'s page"); + // Step 5 Click the Manage button in the Project Info section + employeePage.clickManageProjectInfo(); + TestReporter.assertTrue(employeePage.verifyAddTimesheet3(), "The Project info for "+fullName+" is displayed"); + // Step 6 On one of the timesheets, click the Add button. + employeePage.clickAddTimesheet3(); + TestReporter.assertTrue(employeePage.verifySaveTimesheet(), "Successfully opened the timesheet modal"); + employeePage.assignTimesheetType(); + // Step 7 Right-Click in one of the time fields. + employeePage.rightClickFirstDayOfTimesheet(); + TestReporter.assertTrue(employeePage.verifyCommentBox(), "The comment box is being displayed"); + // Step 8 Enter text into the comment box and click the OK button. + employeePage.populateCommentBox(comment); + // Step 9 Click the Save button + employeePage.clickSaveTimesheet(); + // Step 10 If the message of a locked time sheet is displayed, Click the unlock button and then Click the pencil Icon + TestReporter.assertTrue(employeePage.verifySaveTimesheetMessage(), "Verified the Timesheet was saved successfully"); + employeePage.clickEditTimesheet(); + // Step 11 Repeat steps 7 - 9 and verify that the speech bubble is present and the field is populated with "0" + employeePage.rightClickFirstDayOfTimesheet(); + TestReporter.assertTrue(employeePage.verifyCommentBox(), "The comment box is being displayed"); + TestReporter.assertTrue(employeePage.verifyCommentBox(comment), "Verified the timesheet correctly retains the comment data"); + TestReporter.assertTrue(employeePage.verifyTimesheetTotalHours("0"), "Verified the timesheet still correctly has 0 hours"); + + employeePage.clickSaveTimesheet(); // To reset the test + employeePage.clickDeleteTimesheet(); // To reset the test + } +} \ 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..7d6cf11 100644 --- a/src/test/resources/sandbox.xml +++ b/src/test/resources/sandbox.xml @@ -13,7 +13,7 @@ - +