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
91 changes: 91 additions & 0 deletions src/main/java/com/orasi/bluesource/AccountTimeByTimeSheetForm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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 {
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;
@FindBy(xpath = "//h4[@id='report-title']") private Element elmFormTitle;

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

/**Page Interactions**/

/**
* This method checks that the Time by Time Sheet form is loaded
* @author David Grayson
* @return {@link Boolean} Returns <code>true</code> if the Form is loaded, <code>false</code> otherwise
*/
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);
}

/**
* 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);
}
}

/**
* This method sets the Start Date field
* @author David Grayson
* @param strStartDate {@link String} mm/dd/yyyy format
*/
public void setStartDate(String strStartDate){
if (txtStartDate.syncEnabled(5) && txtStartDate.syncVisible(5)){
txtStartDate.clear();
txtStartDate.sendKeys(strStartDate);
elmFormTitle.click(); //to get rid of the calendar popup
}
}

/**
* This method sets the End Date field
* @author David Grayson
* @param strEndDate {@link String} mm/dd/yyyy format
*/
public void setEndDate(String strEndDate){
if (txtEndDate.syncEnabled(5) && txtEndDate.syncVisible(5)){
txtEndDate.clear();
txtEndDate.sendKeys(strEndDate);
elmFormTitle.click(); //to get rid of the calendar popup
}
}

/**
* This method clicks the Generate Report element
* @author David Grayson
*/
public void clickGenerateReport(){
elmFormTitle.click();
if (driver.findElement(By.xpath("//th[@scope='col']")).syncHidden(5) &&
elmGenerateReport.syncEnabled(5) &&
elmGenerateReport.syncVisible(5)){
elmGenerateReport.click();
}
}
}
18 changes: 13 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 @@ -20,6 +17,7 @@ public class Header {
@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;


/**Constructor**/
public Header(OrasiDriver driver){
Expand All @@ -29,6 +27,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
20 changes: 7 additions & 13 deletions src/main/java/com/orasi/bluesource/LoginPage.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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
*/
Expand All @@ -92,7 +86,7 @@ public void check_login(String username)
}
}

/*
/**
* Method checks that invalid login name and password is handled
* @author: Daniel Smith
*/
Expand Down
69 changes: 69 additions & 0 deletions src/main/java/com/orasi/bluesource/Report.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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**/

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;
int rowBeginSection = 1;
int rowOfSectionTotal = 1;

do {
for (int i=rowBeginSection; i<tblReport.getRowCount(); i++){
if (tblReport.getCell(i,2).getText().equals("Total:")){
rowOfSectionTotal = i;
break;
}
}

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 (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));
}
}
50 changes: 50 additions & 0 deletions src/main/java/com/orasi/bluesource/ReportingNavBar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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 = "//span[contains(text(),'Account Reports')]/..") private Link lnkAccountReportsDropdown;
@FindBy(xpath = "//span[contains(text(),'Account Reports')]/../..//a[contains(text(),'Time by Time Sheet')]") private Link lnkAccountTimeByTimeSheet;
@FindBy(xpath = "//h1[text()='Welcome']") private Element elmWelcome;

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

/**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 <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,80 @@
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 AccountReportsTimeByTimeSheet 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 accountReportsTimeByTimeSheet() {
//Test Variables
String strAccount = "Account1";
String strStartDate = "12/01/2017";
String strEndDate = "03/07/2018";

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

TestReporter.logStep("Navigating to reports login page");
header.navigateReporting();

TestReporter.assertTrue(loginPage.verifyPageIsLoaded(),"Verifying reporting login page is displayed");

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

TestReporter.assertTrue(reportingNavBar.verifyHomePageIsDisplayed(),"Verifying Reporting Home page is Displayed");

TestReporter.logStep("Expanding Account Reports");
reportingNavBar.clickAccountReportsDropdown();

TestReporter.logStep("Clicking Time by Time Sheet");
reportingNavBar.clickAccountTimeByTimeSheet();

TestReporter.assertTrue(accountTimeByTimeSheetForm.verifyAccountTimeByTimeSheetFormLoaded(),"Verifying Time by Time Sheet form loaded");

TestReporter.logStep("Selecting Account [" + strAccount + "]");
accountTimeByTimeSheetForm.selectAccount(strAccount);

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

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

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

TestReporter.assertTrue(report.verifyReportIsLoaded(),"Verifying Report page is loaded");

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

TestReporter.assertEquals(report.getTitle(),"Time by Time Sheet: "+strStartDate+"-"+strEndDate,"Verifying Report Title");
}
}