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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/bin/
/lib/
/src/test/resources/localRegression.xml
/.idea/
108 changes: 108 additions & 0 deletions src/main/java/com/orasi/bluesource/EmployeeTimeByTimeSheetForm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
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.Textbox;
import com.orasi.web.webelements.Webtable;
import com.orasi.web.webelements.impl.internal.ElementFactory;
import org.openqa.selenium.support.FindBy;

import java.util.List;

public class EmployeeTimeByTimeSheetForm {
private OrasiDriver driver = null;

/**Page Elements**/
@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 = "//span[@class='select2-selection select2-selection--single']") private Element elmEmployeeSelect;
@FindBy(xpath = "//span[@class='select2-results']/ul/li") private List<Element> employeeOptions;
@FindBy(xpath = "//h4[@id='report-title']") private Element elmFormHeader;
@FindBy(xpath = "//span[@class='select2-dropdown select2-dropdown--below']") private Element elmEmployeeList;
@FindBy(xpath = "//table[@class='ui-datepicker-calendar']") private Webtable tblCalendarPopup;

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

/**Page Interactions**/

/**
* 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 strEndDate {@link String} mm/dd/yyyy format
*/
public void setEndDate(String strEndDate){
if (canInteract(txtEndDate)){
txtEndDate.clear();
txtEndDate.sendKeys(strEndDate);
elmFormHeader.click();
}
}

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

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

/**
* This method selects an employee from the list that appears
* @author David Grayson
* @param strEmployee {@link String} full name of employee to select
*/
public void selectEmployee(String strEmployee){
if (canInteract(elmEmployeeSelect)){
elmEmployeeSelect.click();
for (Element employee:employeeOptions){
if (employee.getText().equals(strEmployee)){
employee.scrollIntoView();
employee.click();
break;
}
}
}
}

/**
* This method check that the elements essential to filling out the form are loaded
* @author David Grayson
* @return {@link Boolean} Returns <code>true</code> if the the form is loaded, <code>false</code> otherwise
*/
public boolean verifyFormLoaded() {
return PageLoaded.isElementLoaded(this.getClass(),driver,elmEmployeeSelect,5) &&
PageLoaded.isElementLoaded(this.getClass(),driver,txtEndDate,5) &&
PageLoaded.isElementLoaded(this.getClass(),driver,txtStartDate,5) &&
PageLoaded.isElementLoaded(this.getClass(),driver,elmGenerateReport,5);
}
}
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
114 changes: 114 additions & 0 deletions src/main/java/com/orasi/bluesource/Report.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
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;

import java.util.ArrayList;
import java.util.List;

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 List<String>} Returns all employees in the report
*/
public List<String> getEmployees(){
ArrayList<String> employees = new ArrayList<>();
for (int i = 1; i <= tblReport.getRowCount(); i++) {
String cell = tblReport.getCell(i,2).getText();
if (!cell.equals("Total:") && !cell.isEmpty()){
TestReporter.log(cell);
employees.add(cell);
}
}
return employees;
}

/**
* @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));
}
}
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 = "//h1[text()='Welcome']") private Element elmWelcome;
@FindBy(xpath = "//span[contains(text(),'Employee Reports')]/..") private Link lnkEmployeeReportsDropDown;
@FindBy(xpath = "//span[contains(text(),'Employee Reports')]/../..//a[contains(text(),'Time by Time Sheet')]") private Link lnkEmployeeTimeByTimeSheet;

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

/**Page Interactions**/

/**
* @author David Grayson
* @return {@link Boolean} Returns <code>true</code> if on the Reporting Home page.
*/
public boolean verifyHomePageIsDisplayed(){
return elmWelcome.syncVisible(5,false);
}

/**
* This method expands the Employee Reports drop down
* @author David Grayson
*/
public void clickEmployeeReportsDropDown(){
if (lnkEmployeeReportsDropDown.syncEnabled(5) && lnkEmployeeReportsDropDown.syncVisible(5))
lnkEmployeeReportsDropDown.click();
}

/**
* This method clicks on the "Time by Time Sheet" link in the Employee Reports dropdown
* @author David Grayson
*/
public void clickEmployeeTimeByTimeSheet(){
if (lnkEmployeeTimeByTimeSheet.syncEnabled(5) && lnkEmployeeTimeByTimeSheet.syncVisible(5))
lnkEmployeeTimeByTimeSheet.click();
}
}
Loading