From 8404b8a223d2ef2f62e365788cc4cbec0a883667 Mon Sep 17 00:00:00 2001 From: Shahrukh Rehman Date: Thu, 1 Mar 2018 12:36:20 -0500 Subject: [PATCH 1/3] Completed AddRoleType Test --- .classpath | 4 +- pom.xml | 2 +- .../com/orasi/bluesource/AddRoleType.java | 179 ++++++++++++++++++ .../com/bluesource/Admin/Add_Role_Type.java | 69 +++++++ src/test/resources/sandbox.xml | 3 +- 5 files changed, 253 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/orasi/bluesource/AddRoleType.java create mode 100644 src/test/java/com/bluesource/Admin/Add_Role_Type.java diff --git a/.classpath b/.classpath index 62a6877..ace8266 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/pom.xml b/pom.xml index 57f10b1..98d3b57 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 1.1.2 jar - 1.8.5 + 1.8.13 ${env.BUILD_ID} ${env.BUILD_NUMBER} ${env.BUILD_TAG} diff --git a/src/main/java/com/orasi/bluesource/AddRoleType.java b/src/main/java/com/orasi/bluesource/AddRoleType.java new file mode 100644 index 0000000..2958ad4 --- /dev/null +++ b/src/main/java/com/orasi/bluesource/AddRoleType.java @@ -0,0 +1,179 @@ +package com.orasi.bluesource; + +import org.openqa.selenium.By; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.Select; +import org.openqa.selenium.support.ui.WebDriverWait; + +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.Link; +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; + +public class AddRoleType { + + private OrasiDriver driver = null; + + @FindBy(linkText = "Admin") private Link lnkAdminTab; + @FindBy(linkText = "Role Types") private Link lnkRoleTypes; + @FindBy(linkText = "Add New Role Type") private Link lnkAddNewRoleTypeButton; + @FindBy(id = "role_type_name") private Textbox txtRoleName; + @FindBy(id = "role_type_billable") private Checkbox billableCheckBox; + @FindBy(name = "commit") private Button btnCreateRoleType; + @FindBy(css = "table.table-responsive.table-bordered") private Webtable rolesTable; + @FindBy(xpath = "//*[@id=\'new_role\']/div[1]/div/div") private Element billingLbl; + @FindBy(css = "table.table-striped.table-hover") private Webtable projectsTable; + @FindBy(xpath = "//*[@id=\"accordion\"]/div/div[13]/div/div[1]/button[1]") private Button newRoleButton; + @FindBy(xpath = "//*[@id=\"new_role\"]/div[1]/div/div") private Label lblBilling; + @FindBy(id = "role_role_type_id") private Listbox listRoleTypes; + @FindBy(xpath = "//input[@value='Create Role']") private Button btnAssignRoleType; + + private String newRoleTypeName; + + public AddRoleType(OrasiDriver driver){ + this.driver = driver; + ElementFactory.initElements(driver, this); + } + + public void openRoleType() { + + if (lnkAdminTab.isDisplayed() == true) + { + lnkAdminTab.click(); + lnkRoleTypes.click(); + } + } + + public void click_AddNewRoleTypeButton() { + + if (lnkAddNewRoleTypeButton.isDisplayed() == true) + { + + lnkAddNewRoleTypeButton.click(); + } + } + + public void createNewRole(String roleType) { + + this.newRoleTypeName = roleType; + + if (txtRoleName.isDisplayed()==true) { + txtRoleName.sendKeys(newRoleTypeName); + billableCheckBox.uncheck(); + + Select select = new Select(driver.findElement(By.name("role_type[permission]"))); + select.selectByValue("View"); + + btnCreateRoleType.click(); + } + } + + + public boolean verifyNewRole() { + + Boolean verify = true; + + if (rolesTable.isDisplayed() == verify) { + + if (rolesTable.getRowWithCellText(newRoleTypeName) > 0) { + System.out.println("New Role Type is created"); + } + else { + System.out.println("New role type is not created"); + verify = false; + } + } + + return verify; + } + + public int getProjectsTableRows() { + int rowCount = 0; + try + { + rowCount = projectsTable.getRowCount(); + } + catch(NullPointerException e) + { + System.out.println("Null pointer exception, no accounts found \n" + e.getLocalizedMessage()); + } + return (rowCount); + } + + public void openFirstProject() { + if (projectsTable.isDisplayed() == true) { + + if (getProjectsTableRows() > 0) { + projectsTable.getCell(2, 1).findElement( + By.xpath("//*[@id=\'panel_body_1\']/div/table/tbody/tr[1]/td[1]/a")).click(); + } + else { + System.out.println("Projects not found"); + } + } + } + + public void clickNewRole() { + if (newRoleButton.isDisplayed() == true) { + newRoleButton.click(); + } + else { + System.out.println("New Role Button was not found"); + } + } + + public void toggleBilling() { + if (lblBilling.isEnabled() == true) { + String str = lblBilling.getAttribute("class"); + if (str.contains("toggle btn btn-xs btn-primary")) { + lblBilling.jsClick(); + System.out.println("New Label is : " + lblBilling.getAttribute("class")); + } + else { + System.out.println("No need to change because it is already: " + + lblBilling.getAttribute("class")); + } + + } + } + + public void assignNewRole() { + + listRoleTypes.syncVisible(5); + + listRoleTypes.select(newRoleTypeName); + + btnAssignRoleType.click(); + } + + + + + + + + + + + + + + + + + + + + + + + + +} diff --git a/src/test/java/com/bluesource/Admin/Add_Role_Type.java b/src/test/java/com/bluesource/Admin/Add_Role_Type.java new file mode 100644 index 0000000..34e7d15 --- /dev/null +++ b/src/test/java/com/bluesource/Admin/Add_Role_Type.java @@ -0,0 +1,69 @@ +package com.bluesource.Admin; + +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.Accounts; +import com.orasi.bluesource.AddRoleType; +import com.orasi.bluesource.LoginPage; +import com.orasi.utils.TestReporter; +import com.orasi.web.WebBaseTest; + +public class Add_Role_Type 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("Create_Basic_Employee"); + } + + @AfterMethod + public void close(ITestContext testResults){ + endTest("TestAlert", testResults); + } + + @Test(groups = {"smoke"} ) + public void addNewRoleType() { + + TestReporter.setDebugLevel(2); + + TestReporter.logScenario("Add Role Type"); + + setPageURL("http://10.238.243.127/login"); + + testStart("Add Role Type"); + + LoginPage loginPage = new LoginPage(getDriver()); + Accounts accounts = new Accounts(getDriver()); + loginPage.LoginWithCredentials("company.admin", "anything"); + + AddRoleType addNewRoleType = new AddRoleType(getDriver()); + addNewRoleType.openRoleType(); + addNewRoleType.click_AddNewRoleTypeButton(); + addNewRoleType.createNewRole("Automation Tester"); + + if (addNewRoleType.verifyNewRole() == true) { + accounts.click_accounts_tab("company.admin"); + + accounts.clickFirstAccountLink(); + addNewRoleType.openFirstProject(); + addNewRoleType.clickNewRole(); + addNewRoleType.toggleBilling(); + addNewRoleType.assignNewRole(); + } + } + +} diff --git a/src/test/resources/sandbox.xml b/src/test/resources/sandbox.xml index 37bb0d4..ea02eaf 100644 --- a/src/test/resources/sandbox.xml +++ b/src/test/resources/sandbox.xml @@ -13,7 +13,8 @@ - + + From 4923ae898f8501442d8ba9ada74191ea986959dc Mon Sep 17 00:00:00 2001 From: Shahrukh Rehman Date: Wed, 7 Mar 2018 08:25:46 -0500 Subject: [PATCH 2/3] Locked Timesheets --- .../com/orasi/bluesource/LockedTimesheet.java | 279 ++++++++++++++++++ .../bluesource/Admin/Locked_Timesheet.java | 71 +++++ src/test/resources/sandbox.xml | 2 +- 3 files changed, 351 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/orasi/bluesource/LockedTimesheet.java create mode 100644 src/test/java/com/bluesource/Admin/Locked_Timesheet.java diff --git a/src/main/java/com/orasi/bluesource/LockedTimesheet.java b/src/main/java/com/orasi/bluesource/LockedTimesheet.java new file mode 100644 index 0000000..e0ac977 --- /dev/null +++ b/src/main/java/com/orasi/bluesource/LockedTimesheet.java @@ -0,0 +1,279 @@ +package com.orasi.bluesource; + +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +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.Link; +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; + +public class LockedTimesheet { + + private OrasiDriver driver = null; + + /**Page Elements**/ + @FindBy(linkText = "Admin") private Link lnkAdminTab; + @FindBy(linkText = "Timesheet Locks") private Link lnkTimesheetLocks; + @FindBy(linkText = "Logout") private Link lnkLogout; + @FindBy(linkText = "Manage") private Link lnkManage; + @FindBy(linkText = "February") private Link lnkChangeMonth; + @FindBy(linkText = "Employee Reports") private Link lnkEmployeeReports; + @FindBy(linkText = "Time by Project") private Link lnkTimeByProject; + @FindBy(linkText = "Time by Role") private Link lnkTimeByRole; + @FindBy(linkText = "Time by Time Sheet") private Link lnkTimeByTimeSheet; + @FindBy(linkText = "Billing by Project") private Link lnkBillingByProject; + @FindBy(linkText = "Billing by Role") private Link lnkBillingByRole; + @FindBy(linkText = "Combined Total Hours") private Link lnkCombinedTotalHours; + @FindBy(id = "date_month") private Listbox listMonths; + @FindBy(id = "flavor") private Listbox listBillingType; + @FindBy(xpath = "//*[@id='employee_list']/div/span/span[1]/span/span[2]") private Button btnDownArrow; + @FindBy(xpath = "//input[@class='select2-search__field']") private Textbox txtEmployee; + @FindBy(xpath = "//input[@value='Create Lock']") private Button btnCreateLock; + @FindBy(xpath = "//*[@id='notification-area']/div") private Label lblSuccessAlert; + @FindBy(xpath = "//*[@id='reportTable']//*[text()='No results returned by this report']") private Label lblEmployeeReport; + @FindBy(id = "select_date_range") private Button btnGo; + @FindBy(name = "commit") private Button btnGenerateReport; + @FindBy(xpath = "//*[@class=\"time-summary-table table\"]/tbody/tr[4]/td/a") private Button btnAdd; + @FindBy(xpath = "//input[@type='submit' and @value='Submit']") private Button submitTimesheet; + @FindBy(id = "start_date") private Textbox startDateSelector; + @FindBy(id = "end_date") private Textbox endDateSelector; + @FindBy(id = "DataTables_Table_0") private Webtable tblTimesheet; + + + /**Constructor**/ + public LockedTimesheet(OrasiDriver driver){ + this.driver = driver; + ElementFactory.initElements(driver, this); + } + + /* + * Click on accounts tab and then click on timesheet locks + * author: Shahrukh Rehman + */ + public void openLockedTimesheet() { + + if (lnkAdminTab.isDisplayed() == true) + { + lnkAdminTab.click(); + lnkTimesheetLocks.click(); + } + } + + /* + * Create a locked timesheet + * author: Shahrukh Rehman + */ + public void createLockedTimesheet(String month) { + + listMonths.syncVisible(5); + listMonths.select(month); + btnCreateLock.click(); + } + + /* + * Verify successful timesheet lock + * author: Shahrukh Rehman + */ + public boolean verifySuccessAlert() { + + driver.switchTo().alert().accept(); + + Boolean visible = true; + + lblSuccessAlert.syncVisible(10); + + if (lblSuccessAlert.isDisplayed()== visible) { + System.out.println("Timesheet Locked"); + } + else { + visible = false; + } + + return visible; + } + + /* + * Click on logout tab + * author: Shahrukh Rehman + */ + public void logout() { + lnkLogout.syncVisible(10); + lnkLogout.click(); + } + + public void clickManageButton() { + lnkManage.syncVisible(5); + lnkManage.jsClick(); + } + + public void selectMonthWithLockedTimesheet(String month) { + listMonths.syncVisible(5); + listMonths.select(month); + btnGo.click(); + + } + + /* + * Add new timesheet for the employee + * author: Shahrukh Rehman + */ + public void addNewTimesheet(String billingType) { + + btnAdd.syncVisible(10); + btnAdd.click(); + + listBillingType.syncVisible(10); + listBillingType.select(billingType); + + for (int i = 2; i < 7; i++) { + WebElement cellText = driver.findElement(By.xpath("//*[@class=\"time-row\"]/td[" + i + "]/div/input[2]")); + cellText.click(); + cellText.sendKeys("8"); + } + + submitTimesheet.click(); + } + + /* + * Verify timesheet is created + * author: Shahrukh Rehman + */ + public boolean verifySecondSuccessAlert() { + + Boolean visible = true; + + lblSuccessAlert.syncVisible(10); + + if (lblSuccessAlert.isDisplayed()== visible) { + System.out.println("Timesheet Submitted"); + } + else { + visible = false; + } + + return visible; + } + + /* + * Different Login + * author: Shahrukh Rehman + */ + public void newLogin (OrasiDriver driver){ + driver.get("http://10.238.243.127:8080/reporting/login"); + } + + public void clickEmployeeReportsTab() { + + lnkEmployeeReports.syncVisible(10); + lnkEmployeeReports.click(); + } + + /* + * Check time by project + * author: Shahrukh Rehman + */ + public void checkTimeByProjectTab(String employeeFullName, String startDate, String endDate) { + clickEmployeeReportsTab(); + lnkTimeByProject.syncVisible(10); + lnkTimeByProject.click(); + generateReport(employeeFullName, startDate, endDate); + } + + /* + * Check time by Role + * author: Shahrukh Rehman + */ + public void checkTimeByRoleTab(String employeeFullName, String startDate, String endDate) { + clickEmployeeReportsTab(); + lnkTimeByRole.syncVisible(10); + lnkTimeByRole.click(); + generateReport(employeeFullName, startDate, endDate); + } + + /* + * Check time by Timesheet + * author: Shahrukh Rehman + */ + public void checkTimeByTimeSheetTab(String employeeFullName, String startDate, String endDate) { + clickEmployeeReportsTab(); + lnkTimeByTimeSheet.syncVisible(10); + lnkTimeByTimeSheet.click(); + generateReport(employeeFullName, startDate, endDate); + } + + /* + * Check billing by project + * author: Shahrukh Rehman + */ + public void checkBillingByProjectTab(String employeeFullName, String startDate, String endDate) { + clickEmployeeReportsTab(); + lnkBillingByProject.syncVisible(10); + lnkBillingByProject.click(); + generateReport(employeeFullName, startDate, endDate); + } + + /* + * Check billing by role + * author: Shahrukh Rehman + */ + public void checkBillingByRoleTab(String employeeFullName, String startDate, String endDate) { + clickEmployeeReportsTab(); + lnkBillingByRole.syncVisible(10); + lnkBillingByRole.click(); + generateReport(employeeFullName, startDate, endDate); + } + + /* + * Check combined total hours + * author: Shahrukh Rehman + */ + public void checkCombinedTotalHoursTab(String employeeFullName, String startDate, String endDate) { + clickEmployeeReportsTab(); + lnkCombinedTotalHours.syncVisible(10); + lnkCombinedTotalHours.click(); + + btnDownArrow.syncVisible(10); + btnDownArrow.click(); + + txtEmployee.set(employeeFullName); + txtEmployee.sendKeys(Keys.RETURN); + + startDateSelector.set(startDate); + + endDateSelector.set(endDate); + + btnGenerateReport.click(); + + tblTimesheet.syncVisible(10); + } + + /* + * Generate reports for each selection + * author: Shahrukh Rehman + */ + public void generateReport(String employeeFullName, String startDate, String endDate) { + + btnDownArrow.syncVisible(10); + btnDownArrow.click(); + + txtEmployee.set(employeeFullName); + txtEmployee.sendKeys(Keys.RETURN); + + startDateSelector.set(startDate); + + endDateSelector.set(endDate); + + btnGenerateReport.click(); + + lblEmployeeReport.syncVisible(10); + + System.out.println("No reports found"); + } + +} diff --git a/src/test/java/com/bluesource/Admin/Locked_Timesheet.java b/src/test/java/com/bluesource/Admin/Locked_Timesheet.java new file mode 100644 index 0000000..f68018d --- /dev/null +++ b/src/test/java/com/bluesource/Admin/Locked_Timesheet.java @@ -0,0 +1,71 @@ +package com.bluesource.Admin; + +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.LockedTimesheet; +import com.orasi.bluesource.LoginPage; +import com.orasi.utils.TestReporter; +import com.orasi.web.WebBaseTest; + +public class Locked_Timesheet 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("Create_Basic_Employee"); + } + + @AfterMethod + public void close(ITestContext testResults){ + endTest("TestAlert", testResults); + } + + @Test(groups = {"smoke"} ) + public void testLockedTimesheet() { + TestReporter.setDebugLevel(2); + + TestReporter.logScenario("Test Locked Timesheet"); + + setPageURL("http://10.238.243.127/login"); + + testStart("Test Locked Timesheet"); + + LoginPage loginPage = new LoginPage(getDriver()); + LockedTimesheet lockedTimesheet = new LockedTimesheet(getDriver()); + + loginPage.LoginWithCredentials("company.admin", "anything"); + lockedTimesheet.openLockedTimesheet(); + lockedTimesheet.createLockedTimesheet("February"); + lockedTimesheet.verifySuccessAlert(); + lockedTimesheet.logout(); + loginPage.verifyPageIsLoaded(); + loginPage.LoginWithCredentials("bbbb", "anything"); + lockedTimesheet.clickManageButton(); + lockedTimesheet.selectMonthWithLockedTimesheet("February"); + lockedTimesheet.addNewTimesheet("Bench"); + lockedTimesheet.verifySecondSuccessAlert(); + lockedTimesheet.logout(); + lockedTimesheet.newLogin(getDriver()); + loginPage.LoginWithCredentials("company.admin", "anything"); + lockedTimesheet.checkTimeByProjectTab("bbbb bbbb", "02/05/2018", "02/11/2018"); + lockedTimesheet.checkTimeByRoleTab("bbbb bbbb", "02/05/2018", "02/11/2018"); + lockedTimesheet.checkTimeByTimeSheetTab("bbbb bbbb", "02/05/2018", "02/11/2018"); + lockedTimesheet.checkBillingByProjectTab("bbbb bbbb", "02/05/2018", "02/11/2018"); + lockedTimesheet.checkBillingByRoleTab("bbbb bbbb", "02/05/2018", "02/11/2018"); + lockedTimesheet.checkCombinedTotalHoursTab("bbbb bbbb", "02/05/2018", "02/11/2018"); + } +} diff --git a/src/test/resources/sandbox.xml b/src/test/resources/sandbox.xml index ea02eaf..44190e7 100644 --- a/src/test/resources/sandbox.xml +++ b/src/test/resources/sandbox.xml @@ -13,7 +13,7 @@ - + From 6c12d96c9b335fb0b949722e3c665f0836fec169 Mon Sep 17 00:00:00 2001 From: Shahrukh Rehman Date: Wed, 7 Mar 2018 16:02:58 -0500 Subject: [PATCH 3/3] Updated Lockedtimesheet --- .../com/orasi/bluesource/LockedTimesheet.java | 225 ++++++++++-------- .../bluesource/Admin/Locked_Timesheet.java | 45 ++-- 2 files changed, 159 insertions(+), 111 deletions(-) diff --git a/src/main/java/com/orasi/bluesource/LockedTimesheet.java b/src/main/java/com/orasi/bluesource/LockedTimesheet.java index e0ac977..db3d168 100644 --- a/src/main/java/com/orasi/bluesource/LockedTimesheet.java +++ b/src/main/java/com/orasi/bluesource/LockedTimesheet.java @@ -16,7 +16,7 @@ public class LockedTimesheet { private OrasiDriver driver = null; - + /**Page Elements**/ @FindBy(linkText = "Admin") private Link lnkAdminTab; @FindBy(linkText = "Timesheet Locks") private Link lnkTimesheetLocks; @@ -39,144 +39,154 @@ public class LockedTimesheet { @FindBy(xpath = "//*[@id='reportTable']//*[text()='No results returned by this report']") private Label lblEmployeeReport; @FindBy(id = "select_date_range") private Button btnGo; @FindBy(name = "commit") private Button btnGenerateReport; - @FindBy(xpath = "//*[@class=\"time-summary-table table\"]/tbody/tr[4]/td/a") private Button btnAdd; + @FindBy(xpath = "//table[@class='time-summary-table table']/tbody/tr[4]/td/a") private Button btnAdd; @FindBy(xpath = "//input[@type='submit' and @value='Submit']") private Button submitTimesheet; @FindBy(id = "start_date") private Textbox startDateSelector; @FindBy(id = "end_date") private Textbox endDateSelector; @FindBy(id = "DataTables_Table_0") private Webtable tblTimesheet; - - + + /**Constructor**/ public LockedTimesheet(OrasiDriver driver){ this.driver = driver; ElementFactory.initElements(driver, this); } - - /* + + /** * Click on accounts tab and then click on timesheet locks - * author: Shahrukh Rehman + * @author shahrukh.rehman */ - public void openLockedTimesheet() { + public boolean clickTimesheetLocks() { - if (lnkAdminTab.isDisplayed() == true) + if (lnkAdminTab.syncVisible(10)) { lnkAdminTab.click(); lnkTimesheetLocks.click(); + return true; + } + else { + return false; } } - - /* + + /** * Create a locked timesheet - * author: Shahrukh Rehman + * @author shahrukh.rehman */ - public void createLockedTimesheet(String month) { + public boolean createLockedTimesheet(String month) { + + if (listMonths.syncVisible(5)) + { + listMonths.select(month); + btnCreateLock.click(); + return true; + } + else { + return false; + } - listMonths.syncVisible(5); - listMonths.select(month); - btnCreateLock.click(); } - /* + /** * Verify successful timesheet lock - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public boolean verifySuccessAlert() { driver.switchTo().alert().accept(); - Boolean visible = true; - - lblSuccessAlert.syncVisible(10); - - if (lblSuccessAlert.isDisplayed()== visible) { - System.out.println("Timesheet Locked"); + if (lblSuccessAlert.syncVisible(10)) { + return true; } else { - visible = false; + return false; } - - return visible; } - - /* + + /** * Click on logout tab - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public void logout() { lnkLogout.syncVisible(10); lnkLogout.click(); } - - public void clickManageButton() { - lnkManage.syncVisible(5); - lnkManage.jsClick(); + + public boolean clickManageButton() { + if (lnkManage.syncVisible(5)) { + lnkManage.jsClick(); + return true; + } + else { + return false; + } } - - public void selectMonthWithLockedTimesheet(String month) { - listMonths.syncVisible(5); - listMonths.select(month); - btnGo.click(); + public boolean selectMonthWithLockedTimesheet(String month) { + if (listMonths.syncVisible(5)) { + listMonths.select(month); + btnGo.click(); + return true; + } + else { + return false; + } } - - /* + + /** * Add new timesheet for the employee - * author: Shahrukh Rehman + * @param billingType {@link String} + * @author shahrukh.rehman */ public void addNewTimesheet(String billingType) { - btnAdd.syncVisible(10); + if (btnAdd.syncVisible(10)) { btnAdd.click(); - - listBillingType.syncVisible(10); + } + if (listBillingType.syncVisible(10)) { listBillingType.select(billingType); - + } + for (int i = 2; i < 7; i++) { WebElement cellText = driver.findElement(By.xpath("//*[@class=\"time-row\"]/td[" + i + "]/div/input[2]")); cellText.click(); cellText.sendKeys("8"); } - + submitTimesheet.click(); } - - /* + + /** * Verify timesheet is created - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public boolean verifySecondSuccessAlert() { - Boolean visible = true; - - lblSuccessAlert.syncVisible(10); - - if (lblSuccessAlert.isDisplayed()== visible) { - System.out.println("Timesheet Submitted"); + if (lblSuccessAlert.syncVisible(10)) { + return true; } else { - visible = false; + return false; } - - return visible; } - - /* + + /** * Different Login - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public void newLogin (OrasiDriver driver){ driver.get("http://10.238.243.127:8080/reporting/login"); } - + public void clickEmployeeReportsTab() { lnkEmployeeReports.syncVisible(10); lnkEmployeeReports.click(); } - - /* + + /** * Check time by project - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public void checkTimeByProjectTab(String employeeFullName, String startDate, String endDate) { clickEmployeeReportsTab(); @@ -184,10 +194,10 @@ public void checkTimeByProjectTab(String employeeFullName, String startDate, Str lnkTimeByProject.click(); generateReport(employeeFullName, startDate, endDate); } - - /* + + /** * Check time by Role - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public void checkTimeByRoleTab(String employeeFullName, String startDate, String endDate) { clickEmployeeReportsTab(); @@ -195,10 +205,10 @@ public void checkTimeByRoleTab(String employeeFullName, String startDate, String lnkTimeByRole.click(); generateReport(employeeFullName, startDate, endDate); } - - /* + + /** * Check time by Timesheet - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public void checkTimeByTimeSheetTab(String employeeFullName, String startDate, String endDate) { clickEmployeeReportsTab(); @@ -206,10 +216,10 @@ public void checkTimeByTimeSheetTab(String employeeFullName, String startDate, S lnkTimeByTimeSheet.click(); generateReport(employeeFullName, startDate, endDate); } - - /* + + /** * Check billing by project - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public void checkBillingByProjectTab(String employeeFullName, String startDate, String endDate) { clickEmployeeReportsTab(); @@ -217,10 +227,10 @@ public void checkBillingByProjectTab(String employeeFullName, String startDate, lnkBillingByProject.click(); generateReport(employeeFullName, startDate, endDate); } - - /* + + /** * Check billing by role - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public void checkBillingByRoleTab(String employeeFullName, String startDate, String endDate) { clickEmployeeReportsTab(); @@ -228,52 +238,75 @@ public void checkBillingByRoleTab(String employeeFullName, String startDate, Str lnkBillingByRole.click(); generateReport(employeeFullName, startDate, endDate); } - - /* + + /** * Check combined total hours - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public void checkCombinedTotalHoursTab(String employeeFullName, String startDate, String endDate) { clickEmployeeReportsTab(); lnkCombinedTotalHours.syncVisible(10); lnkCombinedTotalHours.click(); - + btnDownArrow.syncVisible(10); btnDownArrow.click(); - + txtEmployee.set(employeeFullName); txtEmployee.sendKeys(Keys.RETURN); - + startDateSelector.set(startDate); endDateSelector.set(endDate); - + btnGenerateReport.click(); - - tblTimesheet.syncVisible(10); + } - /* + /** + * Total hours table displayed + * @author shahrukh.rehman + */ + public boolean totalHoursTableDisplayed() { + if (tblTimesheet.syncVisible(10)) { + + return true; + } + else { + return false; + } + } + + /** * Generate reports for each selection - * author: Shahrukh Rehman + * @author shahrukh.rehman */ public void generateReport(String employeeFullName, String startDate, String endDate) { btnDownArrow.syncVisible(10); btnDownArrow.click(); - + txtEmployee.set(employeeFullName); txtEmployee.sendKeys(Keys.RETURN); - + startDateSelector.set(startDate); endDateSelector.set(endDate); - + btnGenerateReport.click(); - - lblEmployeeReport.syncVisible(10); - - System.out.println("No reports found"); + } + + /** + * No results are displayed + * @author shahrukh.rehman + */ + public boolean noReportsMsgDisplayed() { + if (lblEmployeeReport.syncVisible(10)) { + + return true; + } + else { + return false; + } } } diff --git a/src/test/java/com/bluesource/Admin/Locked_Timesheet.java b/src/test/java/com/bluesource/Admin/Locked_Timesheet.java index f68018d..1cdfa55 100644 --- a/src/test/java/com/bluesource/Admin/Locked_Timesheet.java +++ b/src/test/java/com/bluesource/Admin/Locked_Timesheet.java @@ -26,7 +26,7 @@ public void setup(@Optional String runLocation, String browserUnderTest, setRunLocation(runLocation); setEnvironment(environment); setThreadDriver(true); - testStart("Create_Basic_Employee"); + testStart("Test Locked Timesheet"); } @AfterMethod @@ -47,25 +47,40 @@ public void testLockedTimesheet() { LoginPage loginPage = new LoginPage(getDriver()); LockedTimesheet lockedTimesheet = new LockedTimesheet(getDriver()); + TestReporter.assertTrue(loginPage.verifyPageIsLoaded(), "Page Loaded"); + + //admin login loginPage.LoginWithCredentials("company.admin", "anything"); - lockedTimesheet.openLockedTimesheet(); - lockedTimesheet.createLockedTimesheet("February"); - lockedTimesheet.verifySuccessAlert(); + + TestReporter.assertTrue(lockedTimesheet.clickTimesheetLocks(), "Timesheet Locks link clicked"); + TestReporter.assertTrue(lockedTimesheet.createLockedTimesheet("February"), "Lock Timesheet"); + TestReporter.assertTrue(lockedTimesheet.verifySuccessAlert(), "Timesheet Locked Successfully"); lockedTimesheet.logout(); - loginPage.verifyPageIsLoaded(); - loginPage.LoginWithCredentials("bbbb", "anything"); - lockedTimesheet.clickManageButton(); - lockedTimesheet.selectMonthWithLockedTimesheet("February"); + TestReporter.assertTrue(loginPage.verifyPageIsLoaded(), "Successfully logged out"); + + //employee login + loginPage.LoginWithCredentials("wwww", "anything"); + TestReporter.assertTrue(lockedTimesheet.clickManageButton(), "Manage button clicked"); + TestReporter.assertTrue(lockedTimesheet.selectMonthWithLockedTimesheet("February"), "Month Selected"); lockedTimesheet.addNewTimesheet("Bench"); - lockedTimesheet.verifySecondSuccessAlert(); + TestReporter.assertTrue(lockedTimesheet.verifySecondSuccessAlert(), "Locked timesheet created"); lockedTimesheet.logout(); + + //Employee reports lockedTimesheet.newLogin(getDriver()); loginPage.LoginWithCredentials("company.admin", "anything"); - lockedTimesheet.checkTimeByProjectTab("bbbb bbbb", "02/05/2018", "02/11/2018"); - lockedTimesheet.checkTimeByRoleTab("bbbb bbbb", "02/05/2018", "02/11/2018"); - lockedTimesheet.checkTimeByTimeSheetTab("bbbb bbbb", "02/05/2018", "02/11/2018"); - lockedTimesheet.checkBillingByProjectTab("bbbb bbbb", "02/05/2018", "02/11/2018"); - lockedTimesheet.checkBillingByRoleTab("bbbb bbbb", "02/05/2018", "02/11/2018"); - lockedTimesheet.checkCombinedTotalHoursTab("bbbb bbbb", "02/05/2018", "02/11/2018"); + + lockedTimesheet.checkTimeByProjectTab("wwww bbbb", "02/05/2018", "02/11/2018"); + TestReporter.assertTrue(lockedTimesheet.noReportsMsgDisplayed(), "No results are displayed"); + lockedTimesheet.checkTimeByRoleTab("wwww bbbb", "02/05/2018", "02/11/2018"); + TestReporter.assertTrue(lockedTimesheet.noReportsMsgDisplayed(), "No results are displayed"); + lockedTimesheet.checkTimeByTimeSheetTab("wwww bbbb", "02/05/2018", "02/11/2018"); + TestReporter.assertTrue(lockedTimesheet.noReportsMsgDisplayed(), "No results are displayed"); + lockedTimesheet.checkBillingByProjectTab("wwww bbbb", "02/05/2018", "02/11/2018"); + TestReporter.assertTrue(lockedTimesheet.noReportsMsgDisplayed(), "No results are displayed"); + lockedTimesheet.checkBillingByRoleTab("wwww bbbb", "02/05/2018", "02/11/2018"); + TestReporter.assertTrue(lockedTimesheet.noReportsMsgDisplayed(), "No results are displayed"); + lockedTimesheet.checkCombinedTotalHoursTab("wwww bbbb", "02/05/2018", "02/11/2018"); + TestReporter.assertTrue(lockedTimesheet.totalHoursTableDisplayed(), "Table is displayed"); } }