From 2fec50be2853fb9013ef6e421eb84147868d1d1d Mon Sep 17 00:00:00 2001 From: "david.grayson" Date: Tue, 6 Mar 2018 16:18:01 -0500 Subject: [PATCH 1/3] committing to go work on another branch --- .../AccountTimeByTimeSheetForm.java | 52 +++++++++++++++++ .../java/com/orasi/bluesource/Header.java | 12 ++-- .../java/com/orasi/bluesource/Report.java | 57 +++++++++++++++++++ .../com/orasi/bluesource/ReportsNavBar.java | 33 +++++++++++ .../AccountReportsTimeByTimesheet.java | 54 ++++++++++++++++++ src/test/resources/sandbox.xml | 2 +- 6 files changed, 204 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java create mode 100644 src/main/java/com/orasi/bluesource/Report.java create mode 100644 src/main/java/com/orasi/bluesource/ReportsNavBar.java create mode 100644 src/test/java/com/bluesource/reports/AccountReportsTimeByTimesheet.java diff --git a/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java b/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java new file mode 100644 index 0000000..9727d99 --- /dev/null +++ b/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java @@ -0,0 +1,52 @@ +package com.orasi.bluesource; + +import com.orasi.web.OrasiDriver; +import com.orasi.web.webelements.Element; +import com.orasi.web.webelements.Listbox; +import com.orasi.web.webelements.Textbox; +import com.orasi.web.webelements.impl.internal.ElementFactory; +import org.openqa.selenium.support.FindBy; + +public class AccountTimeByTimeSheetForm { + private OrasiDriver driver = null; + + /**Page Elements**/ + @FindBy(xpath = "//select[@id='account_select']") private Listbox lstAccountSelect; + @FindBy(xpath = "//input[@name='start_date']") private Textbox txtStartDate; + @FindBy(xpath = "//input[@name='end_date']") private Textbox txtEndDate; + @FindBy(xpath = "//input[@name='commit']") private Element elmGenerateReport; + + /**Constructor**/ + public AccountTimeByTimeSheetForm(OrasiDriver driver){ + this.driver = driver; + ElementFactory.initElements(driver,this); + } + + /**Page Interactions**/ + public void selectAccount(String strAccount){ + lstAccountSelect.syncEnabled(5); + lstAccountSelect.syncVisible(5); + lstAccountSelect.select(strAccount); + } + + public void setStartDate(String strStartDate){ + txtStartDate.syncEnabled(5); + txtStartDate.syncVisible(5); + txtStartDate.clear(); + txtStartDate.sendKeys(strStartDate); + } + + public void setEndDate(String strEndDate){ + txtEndDate.syncEnabled(5); + txtEndDate.syncVisible(5); + txtEndDate.clear(); + txtEndDate.sendKeys(strEndDate); + } + + public void clickGenerateReport(){ + elmGenerateReport.syncEnabled(5); + elmGenerateReport.syncVisible(5); + elmGenerateReport.click(); + } + +} diff --git a/src/main/java/com/orasi/bluesource/Header.java b/src/main/java/com/orasi/bluesource/Header.java index 3522250..55da570 100644 --- a/src/main/java/com/orasi/bluesource/Header.java +++ b/src/main/java/com/orasi/bluesource/Header.java @@ -1,13 +1,10 @@ package com.orasi.bluesource; -import javax.wsdl.Message; - -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.support.FindBy; - import com.orasi.web.OrasiDriver; import com.orasi.web.webelements.Link; import com.orasi.web.webelements.impl.internal.ElementFactory; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.support.FindBy; public class Header { private OrasiDriver driver = null; @@ -18,6 +15,7 @@ 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; + /**Constructor**/ public Header(OrasiDriver driver){ @@ -27,6 +25,10 @@ public Header(OrasiDriver driver){ /**Page Interactions**/ + public void navigateReporting(){ + driver.get("http://10.238.243.127:8080/reporting/login"); + } + /** * This method navigates to Accounts page * @author Paul diff --git a/src/main/java/com/orasi/bluesource/Report.java b/src/main/java/com/orasi/bluesource/Report.java new file mode 100644 index 0000000..3a5ed01 --- /dev/null +++ b/src/main/java/com/orasi/bluesource/Report.java @@ -0,0 +1,57 @@ +package com.orasi.bluesource; + +import com.orasi.web.OrasiDriver; +import com.orasi.web.webelements.Element; +import com.orasi.web.webelements.Webtable; +import com.orasi.web.webelements.impl.internal.ElementFactory; +import org.openqa.selenium.support.FindBy; + +public class Report { + private OrasiDriver driver = null; + + /**Page Elements**/ + @FindBy(xpath = "//h3[@class='report-title']") private Element elmReportTitle; + @FindBy(xpath = "//table") private Webtable tblReport; + + /**Constructor**/ + public Report(OrasiDriver driver){ + this.driver = driver; + ElementFactory.initElements(driver,this); + } + + /**Page Interactions**/ + + public boolean checkTotals(){ + int runningTotal = 0; + int sectionTotal = 0; + int rowBeginSection = 1; + int rowOfSectionTotal = 1; + + do { + for (int i=rowBeginSection; i - + From 0e5cb84ea00e1d671bdf979fcc0738f92c15de48 Mon Sep 17 00:00:00 2001 From: David Grayson Date: Wed, 7 Mar 2018 15:20:01 -0500 Subject: [PATCH 2/3] Test passes --- .../AccountTimeByTimeSheetForm.java | 56 +++++++++---- .../java/com/orasi/bluesource/Header.java | 4 + .../java/com/orasi/bluesource/LoginPage.java | 20 ++--- .../java/com/orasi/bluesource/Report.java | 22 +++-- ...eportsNavBar.java => ReportingNavBar.java} | 20 +++-- .../AccountReportsTimeByTimeSheet.java | 80 +++++++++++++++++++ .../AccountReportsTimeByTimesheet.java | 54 ------------- 7 files changed, 161 insertions(+), 95 deletions(-) rename src/main/java/com/orasi/bluesource/{ReportsNavBar.java => ReportingNavBar.java} (57%) create mode 100644 src/test/java/com/bluesource/reports/AccountReportsTimeByTimeSheet.java delete mode 100644 src/test/java/com/bluesource/reports/AccountReportsTimeByTimesheet.java diff --git a/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java b/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java index 9727d99..7a7d765 100644 --- a/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java +++ b/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java @@ -1,10 +1,12 @@ package com.orasi.bluesource; import com.orasi.web.OrasiDriver; +import com.orasi.web.PageLoaded; import com.orasi.web.webelements.Element; import com.orasi.web.webelements.Listbox; import com.orasi.web.webelements.Textbox; import com.orasi.web.webelements.impl.internal.ElementFactory; +import org.openqa.selenium.By; import org.openqa.selenium.support.FindBy; public class AccountTimeByTimeSheetForm { @@ -15,6 +17,7 @@ public class AccountTimeByTimeSheetForm { @FindBy(xpath = "//input[@name='start_date']") private Textbox txtStartDate; @FindBy(xpath = "//input[@name='end_date']") private Textbox txtEndDate; @FindBy(xpath = "//input[@name='commit']") private Element elmGenerateReport; + @FindBy(xpath = "//h4[@id='report-title']") private Element elmFormTitle; /**Constructor**/ public AccountTimeByTimeSheetForm(OrasiDriver driver){ @@ -23,30 +26,53 @@ public AccountTimeByTimeSheetForm(OrasiDriver driver){ } /**Page Interactions**/ + + public boolean verifyAccountTimeByTimeSheetFormLoaded(){ + return PageLoaded.isElementLoaded(this.getClass(),driver,lstAccountSelect,5) && + PageLoaded.isElementLoaded(this.getClass(),driver,txtStartDate,5) && + PageLoaded.isElementLoaded(this.getClass(),driver,txtEndDate,5) && + PageLoaded.isElementLoaded(this.getClass(),driver,elmGenerateReport); + } + public void selectAccount(String strAccount){ - lstAccountSelect.syncEnabled(5); - lstAccountSelect.syncVisible(5); - lstAccountSelect.select(strAccount); + if (lstAccountSelect.syncEnabled(5) && lstAccountSelect.syncVisible(5)) { + lstAccountSelect.select(strAccount); + } } + /** + * @author David Grayson + * @param strStartDate {@link String} mm/dd/yyyy format + */ public void setStartDate(String strStartDate){ - txtStartDate.syncEnabled(5); - txtStartDate.syncVisible(5); - txtStartDate.clear(); - txtStartDate.sendKeys(strStartDate); + if (txtStartDate.syncEnabled(5) && txtStartDate.syncVisible(5)){ + txtStartDate.clear(); + txtStartDate.sendKeys(strStartDate); + elmFormTitle.click(); //to get rid of the calendar popup + } } + /** + * @author David Grayson + * @param strEndDate {@link String} mm/dd/yyyy format + */ public void setEndDate(String strEndDate){ - txtEndDate.syncEnabled(5); - txtEndDate.syncVisible(5); - txtEndDate.clear(); - txtEndDate.sendKeys(strEndDate); + if (txtEndDate.syncEnabled(5) && txtEndDate.syncVisible(5)){ + txtEndDate.clear(); + txtEndDate.sendKeys(strEndDate); + elmFormTitle.click(); //to get rid of the calendar popup + } } + /** + * @author David Grayson + */ public void clickGenerateReport(){ - elmGenerateReport.syncEnabled(5); - elmGenerateReport.syncVisible(5); - elmGenerateReport.click(); + elmFormTitle.click(); + if (driver.findElement(By.xpath("//th[@scope='col']")).syncHidden(5) && + elmGenerateReport.syncEnabled(5) && + elmGenerateReport.syncVisible(5)){ + elmGenerateReport.click(); + } } - } diff --git a/src/main/java/com/orasi/bluesource/Header.java b/src/main/java/com/orasi/bluesource/Header.java index 55da570..de8d5c9 100644 --- a/src/main/java/com/orasi/bluesource/Header.java +++ b/src/main/java/com/orasi/bluesource/Header.java @@ -25,6 +25,10 @@ public Header(OrasiDriver driver){ /**Page Interactions**/ + /** + * This method navigates to the Reporting login page + * @author David Grayson + */ public void navigateReporting(){ driver.get("http://10.238.243.127:8080/reporting/login"); } diff --git a/src/main/java/com/orasi/bluesource/LoginPage.java b/src/main/java/com/orasi/bluesource/LoginPage.java index 3d71ad5..e868a50 100644 --- a/src/main/java/com/orasi/bluesource/LoginPage.java +++ b/src/main/java/com/orasi/bluesource/LoginPage.java @@ -1,19 +1,14 @@ package com.orasi.bluesource; -import java.util.ResourceBundle; - -import org.openqa.selenium.support.FindBy; - import com.orasi.utils.Constants; import com.orasi.utils.TestReporter; import com.orasi.web.OrasiDriver; import com.orasi.web.PageLoaded; -import com.orasi.web.webelements.Button; -import com.orasi.web.webelements.Element; -import com.orasi.web.webelements.Label; -import com.orasi.web.webelements.Textbox; -import com.orasi.web.webelements.Webtable; +import com.orasi.web.webelements.*; import com.orasi.web.webelements.impl.internal.ElementFactory; +import org.openqa.selenium.support.FindBy; + +import java.util.ResourceBundle; public class LoginPage { @@ -46,8 +41,7 @@ public boolean verifyPageIsLoaded(){ /** * This method logins to the application with provided credentials * @author - * @param username - * @param password + * @param role {@link String} */ public boolean Login(String role){ txtUsername.set(userCredentialRepo.getString(role)); @@ -75,7 +69,7 @@ public void LoginWithCredentials(String username, String password) { btnLogin.jsClick(); } - /* + /** * Method checks that the label welcome is present on the screen * @author: Daniel Smith */ @@ -92,7 +86,7 @@ public void check_login(String username) } } - /* + /** * Method checks that invalid login name and password is handled * @author: Daniel Smith */ diff --git a/src/main/java/com/orasi/bluesource/Report.java b/src/main/java/com/orasi/bluesource/Report.java index 3a5ed01..207ab70 100644 --- a/src/main/java/com/orasi/bluesource/Report.java +++ b/src/main/java/com/orasi/bluesource/Report.java @@ -1,6 +1,8 @@ package com.orasi.bluesource; +import com.orasi.utils.TestReporter; import com.orasi.web.OrasiDriver; +import com.orasi.web.PageLoaded; import com.orasi.web.webelements.Element; import com.orasi.web.webelements.Webtable; import com.orasi.web.webelements.impl.internal.ElementFactory; @@ -21,6 +23,15 @@ public Report(OrasiDriver driver){ /**Page Interactions**/ + public boolean verifyReportIsLoaded(){ + return PageLoaded.isElementLoaded(this.getClass(),driver,elmReportTitle,5) && + PageLoaded.isElementLoaded(this.getClass(),driver,tblReport,5); + } + + public String getTitle(){ + return elmReportTitle.getText(); + } + public boolean checkTotals(){ int runningTotal = 0; int sectionTotal = 0; @@ -36,22 +47,23 @@ public boolean checkTotals(){ } for (int i=rowBeginSection; i Date: Wed, 7 Mar 2018 15:53:26 -0500 Subject: [PATCH 3/3] added comments/documentation --- .../bluesource/AccountTimeByTimeSheetForm.java | 13 +++++++++++++ src/main/java/com/orasi/bluesource/Header.java | 2 ++ src/main/java/com/orasi/bluesource/LoginPage.java | 2 +- .../java/com/orasi/bluesource/ReportingNavBar.java | 13 +++++++++++++ src/test/resources/sandbox.xml | 2 +- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java b/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java index 7a7d765..94e7452 100644 --- a/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java +++ b/src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java @@ -27,6 +27,11 @@ public AccountTimeByTimeSheetForm(OrasiDriver driver){ /**Page Interactions**/ + /** + * This method checks that the Time by Time Sheet form is loaded + * @author David Grayson + * @return {@link Boolean} Returns true if the Form is loaded, false otherwise + */ public boolean verifyAccountTimeByTimeSheetFormLoaded(){ return PageLoaded.isElementLoaded(this.getClass(),driver,lstAccountSelect,5) && PageLoaded.isElementLoaded(this.getClass(),driver,txtStartDate,5) && @@ -34,6 +39,11 @@ public boolean verifyAccountTimeByTimeSheetFormLoaded(){ PageLoaded.isElementLoaded(this.getClass(),driver,elmGenerateReport); } + /** + * This method selects an account by the name passed to it + * @author David Grayson + * @param strAccount {@link String} name of the account + */ public void selectAccount(String strAccount){ if (lstAccountSelect.syncEnabled(5) && lstAccountSelect.syncVisible(5)) { lstAccountSelect.select(strAccount); @@ -41,6 +51,7 @@ public void selectAccount(String strAccount){ } /** + * This method sets the Start Date field * @author David Grayson * @param strStartDate {@link String} mm/dd/yyyy format */ @@ -53,6 +64,7 @@ public void setStartDate(String strStartDate){ } /** + * This method sets the End Date field * @author David Grayson * @param strEndDate {@link String} mm/dd/yyyy format */ @@ -65,6 +77,7 @@ public void setEndDate(String strEndDate){ } /** + * This method clicks the Generate Report element * @author David Grayson */ public void clickGenerateReport(){ diff --git a/src/main/java/com/orasi/bluesource/Header.java b/src/main/java/com/orasi/bluesource/Header.java index de8d5c9..fed993b 100644 --- a/src/main/java/com/orasi/bluesource/Header.java +++ b/src/main/java/com/orasi/bluesource/Header.java @@ -30,6 +30,8 @@ public Header(OrasiDriver driver){ * @author David Grayson */ public void navigateReporting(){ + MessageCenter messageCenter = new MessageCenter(driver); + messageCenter.closeMessageCenter(); driver.get("http://10.238.243.127:8080/reporting/login"); } diff --git a/src/main/java/com/orasi/bluesource/LoginPage.java b/src/main/java/com/orasi/bluesource/LoginPage.java index e868a50..5ad057b 100644 --- a/src/main/java/com/orasi/bluesource/LoginPage.java +++ b/src/main/java/com/orasi/bluesource/LoginPage.java @@ -41,7 +41,7 @@ public boolean verifyPageIsLoaded(){ /** * This method logins to the application with provided credentials * @author - * @param role {@link String} + * @param role {@link String} */ public boolean Login(String role){ txtUsername.set(userCredentialRepo.getString(role)); diff --git a/src/main/java/com/orasi/bluesource/ReportingNavBar.java b/src/main/java/com/orasi/bluesource/ReportingNavBar.java index 6963919..439ea3c 100644 --- a/src/main/java/com/orasi/bluesource/ReportingNavBar.java +++ b/src/main/java/com/orasi/bluesource/ReportingNavBar.java @@ -21,16 +21,29 @@ public ReportingNavBar(OrasiDriver driver){ } /**Page Interactions**/ + + /** + * This method clicks the Time by Time Sheet link in the Account Reports dropdown menu + * @author David Grayson + */ public void clickAccountTimeByTimeSheet(){ if (lnkAccountTimeByTimeSheet.syncEnabled(5) && lnkAccountTimeByTimeSheet.syncVisible(5)) lnkAccountTimeByTimeSheet.click(); } + /** + * This method clicks the Account Reports Drop down + * @author David Grayson + */ public void clickAccountReportsDropdown(){ if (lnkAccountReportsDropdown.syncEnabled(5) && lnkAccountReportsDropdown.syncVisible(5)) lnkAccountReportsDropdown.click(); } + /** + * @author David Grayson + * @return {@link Boolean} Returns true if on the Reporting Home page. + */ public boolean verifyHomePageIsDisplayed(){ return elmWelcome.syncVisible(5,false); } diff --git a/src/test/resources/sandbox.xml b/src/test/resources/sandbox.xml index fee98b0..671d0eb 100644 --- a/src/test/resources/sandbox.xml +++ b/src/test/resources/sandbox.xml @@ -13,7 +13,7 @@ - +