Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/main/java/com/orasi/bluesource/Header.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -27,6 +24,16 @@ public Header(OrasiDriver driver){

/**Page Interactions**/

/**
* This method navigates to the Reporting login page
* @author David Grayson
*/
public void navigateReporting(){
MessageCenter messageCenter = new MessageCenter(driver);
messageCenter.closeMessageCenter();
driver.get("http://10.238.243.127:8080/reporting/login");
}

/**
* This method navigates to Accounts page
* @author Paul
Expand Down
101 changes: 101 additions & 0 deletions src/main/java/com/orasi/bluesource/ProjectTimeByTimeSheetForm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
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.Webtable;
import com.orasi.web.webelements.impl.internal.ElementFactory;
import org.openqa.selenium.support.FindBy;

public class ProjectTimeByTimeSheetForm {
private OrasiDriver driver = null;

/**Page Elements**/
@FindBy(xpath = "//select[@id='project_']") private Listbox lstProjectSelect;
@FindBy(xpath = "//input[@id='start_date']") private Textbox txtStartDate;
@FindBy(xpath = "//input[@id='end_date']") private Textbox txtEndDate;
@FindBy(xpath = "//input[@name='commit']") private Element elmGenerateReport;
@FindBy(xpath = "//table[@class='ui-datepicker-calendar']") private Webtable tblCalendarPopup;
@FindBy(xpath = "//h4[@id='report-title']") private Element elmFormTitle;

/**Constructor**/
public ProjectTimeByTimeSheetForm(OrasiDriver driver) {
this.driver = driver;
ElementFactory.initElements(driver,this);
}

/**Page Interactions**/

/**
* @author David Grayson
* @return {@link Boolean} Returns <code>true</code> if the form is loaded, <code>false</code> otherwise.
*/
public boolean verifyFormIsLoaded(){
return checkLoaded(lstProjectSelect) &&
checkLoaded(txtStartDate) &&
checkLoaded(txtEndDate) &&
checkLoaded(elmGenerateReport);
}

private boolean checkLoaded(Element elm) {
return PageLoaded.isElementLoaded(this.getClass(),driver,elm,5);
}

/**
* This method selects an employee from the list that appears
* @author David Grayson
* @param project {@link String} full name of the Project to select
*/
public void selectProject(String project){
if (canInteract(lstProjectSelect)){
lstProjectSelect.select(project);
}
}

/**
* This method clicks the Generate Report element
* @author David Grayson
*/
public void clickGenerateReport(){
if (canInteract(elmGenerateReport) && tblCalendarPopup.syncHidden(5)){
elmGenerateReport.click();
}
}

/**
* This method sets the End Date field
* @author David Grayson
* @param endDate {@link String} mm/dd/yyyy format
*/
public void setEndDate(String endDate){
if (canInteract(txtEndDate)){
txtEndDate.clear();
txtEndDate.sendKeys(endDate);
}
}

/**
* This method sets the Start Date field
* @author David Grayson
* @param startDate {@link String} mm/dd/yyyy format
*/
public void setStartDate(String startDate){
if (canInteract(txtStartDate)){
txtStartDate.clear();
txtStartDate.sendKeys(startDate);
}
}

/**
* This method provides standard checks that an element can be interacted with
* @author David Grayson
* @param elm {@link Element} Element to check
* @return {@link Boolean} Returns <code>true</code> if the element is enabled and visible, <code>false</code> otherwise
*/
private boolean canInteract(Element elm){
elmFormTitle.click(); //to clear any popups
return elm.syncEnabled(5) && elm.syncVisible(5);
}
}
95 changes: 95 additions & 0 deletions src/main/java/com/orasi/bluesource/Report.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
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;
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**/

/**
* @author David Grayson
* @return {@link Boolean} Returns <code>true</code> if the report is loaded, <code>false</code> otherwise.
*/
public boolean verifyReportIsLoaded(){
return PageLoaded.isElementLoaded(this.getClass(),driver,elmReportTitle,5) &&
PageLoaded.isElementLoaded(this.getClass(),driver,tblReport,5);
}

/**
* @author David Grayson
* @return {@link String} Returns the title of the report
*/
public String getTitle(){
return elmReportTitle.getText();
}

/**
* @author David Grayson
* @return {@link Boolean} Returns <code>true</code> if all the sub totals and the grand total are correct, <code>false</code> otherwise.
*/
public boolean checkTotals(){
int runningTotal = 0;
int sectionTotal = 0;
int rowBeginSection = 1;
int rowOfSectionTotal = 1;

/*
The do while loop iterates over a report of any size and checks all the sub totals and the grand total
to make sure they add up correctly.
*/
do {
/*
This for loop find the row with the "Total:" line to set the ned point for the next section
*/
for (int i=rowBeginSection; i<tblReport.getRowCount(); i++){
if (tblReport.getCell(i,2).getText().equals("Total:")){
rowOfSectionTotal = i;
break;
}
}

/*
this for loop iterates over the section to check the total line at the end
*/
for (int i=rowBeginSection; i<rowOfSectionTotal; i++){
if (tblReport.getCell(i,4).getText().isEmpty())
TestReporter.log(String.valueOf(i));
sectionTotal += Integer.parseInt(tblReport.getCell(i,4).getText());
}

/*
if the total matches then it is added to the runningTotal and the row markers are moved to the next section
if not the the section is logged and false is returned
*/
if (tblReport.getCell(rowOfSectionTotal,4).getText().equals(String.valueOf(sectionTotal))){
rowBeginSection = rowOfSectionTotal += 2;
runningTotal += sectionTotal;
sectionTotal = 0;
}else {
TestReporter.log("rowBeginSection = " + rowBeginSection);
TestReporter.log("rowOfSectionTotal = " + rowOfSectionTotal);
return false;
}

} while(rowBeginSection < tblReport.getRowCount());

return tblReport.getCell(tblReport.getRowCount(), 4).getText().equals(String.valueOf(runningTotal));
}
}
60 changes: 60 additions & 0 deletions src/main/java/com/orasi/bluesource/ReportingNavBar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.orasi.bluesource;

import com.orasi.web.OrasiDriver;
import com.orasi.web.webelements.Element;
import com.orasi.web.webelements.Link;
import com.orasi.web.webelements.impl.internal.ElementFactory;
import org.openqa.selenium.support.FindBy;

public class ReportingNavBar {
private OrasiDriver driver = null;

/**Page Elements**/
@FindBy(xpath = "//h1[text()='Welcome']") private Element elmWelcome;
@FindBy(xpath = "//span[contains(text(),'Projects Reports')]/..") private Link lnkProjectsReport;
@FindBy(xpath = "//span[contains(text(),'Projects Reports')]/../..//a[contains(text(),'Time by Time Sheet')]") private Link lnkProjectsReportTimeByTimeSheet;

/**Constructor**/
public ReportingNavBar(OrasiDriver driver) {
this.driver = driver;
ElementFactory.initElements(driver,this);
}

/**Page Interactions**/

/**
* This method expands the Projects Reports drop down
* @author David Grayson
*/
public void clickProjectsReport(){
if (canInteract(lnkProjectsReport))
lnkProjectsReport.click();
}

/**
* This method clicks on the "Time by Time Sheet" link in the Projects Reports dropdown
* @author David Grayson
*/
public void clickProjectsReportTimeByTimeSheet(){
if (canInteract(lnkProjectsReportTimeByTimeSheet))
lnkProjectsReportTimeByTimeSheet.click();
}

/**
* This method provides standard checks that an element can be interacted with
* @author David Grayson
* @param elm {@link Element} Element to check
* @return {@link Boolean} Returns <code>true</code> if the element is enabled and visible, <code>false</code> otherwise
*/
private boolean canInteract(Element elm){
return elm.syncEnabled(5) && elm.syncVisible(5);
}

/**
* @author David Grayson
* @return {@link Boolean} Returns <code>true</code> if on the Reporting Home page.
*/
public boolean verifyHomePageIsDisplayed(){
return elmWelcome.syncVisible(5,false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.bluesource.reports;

import com.orasi.bluesource.*;
import com.orasi.utils.TestReporter;
import com.orasi.web.WebBaseTest;
import org.testng.ITestContext;
import org.testng.annotations.*;

public class ProjectReportsTimeByTimeSheet 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("");
}

@AfterMethod
public void close(ITestContext testResults) {
endTest("TestAlert", testResults);
}

@Test
public void projectReportsTimeByTimeSheet() {
//Test Variables
String strProject = "Project1";
String strStartDate = "10/01/2017";
String strEndDate = "03/07/2018";
String reportTitle = "Time by Time Sheet: " + strStartDate + "-" + strEndDate;

//Page Models
LoginPage loginPage = new LoginPage(getDriver());
Header header = new Header(getDriver());
ReportingNavBar reportingNavBar = new ReportingNavBar(getDriver());
ProjectTimeByTimeSheetForm projectTimeByTimeSheetForm = new ProjectTimeByTimeSheetForm(getDriver());
Report report = new Report(getDriver());

TestReporter.logStep("Navigating to BlueSourceReport");
header.navigateReporting();

TestReporter.assertTrue(loginPage.verifyPageIsLoaded(),"Verifying login page has loaded");

TestReporter.logStep("Logging in as Admin");
loginPage.AdminLogin();

TestReporter.assertTrue(reportingNavBar.verifyHomePageIsDisplayed(),"Verifying Reporting Home Page is displayed");

TestReporter.logStep("Clicking Projects Reports");
reportingNavBar.clickProjectsReport();

TestReporter.logStep("Clicking 'Time by Time Sheet' under Projects Reports");
reportingNavBar.clickProjectsReportTimeByTimeSheet();

TestReporter.assertTrue(projectTimeByTimeSheetForm.verifyFormIsLoaded(),"Verifying form has loaded");

TestReporter.logStep("Selecting Project");
projectTimeByTimeSheetForm.selectProject(strProject);

TestReporter.logStep("Setting Start Date");
projectTimeByTimeSheetForm.setStartDate(strStartDate);

TestReporter.logStep("Setting End Date");
projectTimeByTimeSheetForm.setEndDate(strEndDate);

TestReporter.logStep("Clicking Generate Report");
projectTimeByTimeSheetForm.clickGenerateReport();

TestReporter.assertTrue(report.verifyReportIsLoaded(),"Verifying report has loaded");

TestReporter.assertEquals(reportTitle,report.getTitle(),"Verifying report title");

TestReporter.assertTrue(report.checkTotals(), "Verifying totals are correct");
}
}