Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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.impl.internal.ElementFactory;
import org.openqa.selenium.support.FindBy;

public class AccountBurnDownDataReportForm {
private OrasiDriver driver = null;

/**Page Elements**/
@FindBy(xpath = "//input[@name='commit']") private Element elmGenerateReport;
@FindBy(xpath = "//select[@id='account_select']") private Listbox lstAccountSelect;

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

/**Page Interactions**/

public boolean verifyFormLoaded(){
return PageLoaded.isElementLoaded(this.getClass(),driver,elmGenerateReport,5) &&
PageLoaded.isElementLoaded(this.getClass(),driver,lstAccountSelect,5);
}

public void clickGenerateReport(){
if (canInteract(elmGenerateReport))
elmGenerateReport.click();
}

public void selectAccount(String strAccount){
if (canInteract(lstAccountSelect)){
lstAccountSelect.select(strAccount);
}
}

/**
* 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);
}
}
153 changes: 128 additions & 25 deletions src/main/java/com/orasi/bluesource/Accounts.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
package com.orasi.bluesource;

import java.lang.reflect.UndeclaredThrowableException;
import java.util.List;

import javax.lang.model.util.Elements;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.orasi.utils.Randomness;
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.Link;
import com.orasi.web.webelements.Listbox;
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.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.support.FindBy;

import java.lang.reflect.UndeclaredThrowableException;
import java.util.List;

public class Accounts {
private OrasiDriver driver = null;
Expand All @@ -46,6 +33,12 @@ public class Accounts {
@FindBy(css = "div.btn.btn-secondary.btn-xs.quick-nav") private Button btnQuickNav;
@FindBy(xpath = "//a[contains(@ng-bind, 'n + 1')]") private List<Button> btnPages;
@FindBy(xpath = "//*[@id=\"project-list\"]/div/div[1]/div") private Button btnCloseQuickNav;
@FindBy(xpath = "//th[contains(text(),'Role')]/../../..") private Webtable tblProjectRoles;
@FindBy(xpath = "//th[contains(text(),'Rate')]/../../..") private Webtable tblRoleRates;
@FindBy(xpath = "//h4[@class='panel-title' and contains(text(),'Project Info')]") private Element elmProjectInfoPanelHeader;
@FindBy(xpath = "//h4[@class='panel-title' and contains(text(),'Role Information')]") private Element elmRoleInfoPanelHeader;
@FindBy(xpath = "//h4[@class='panel-title'and contains(text(),'Documents')]/../button") private Button btnProjectAddDocument;
@FindBy(xpath = "//th[contains(text(),'Document')]/../../..") private Webtable tblDocuments;

/**Constructor**/
public Accounts(OrasiDriver driver){
Expand All @@ -55,10 +48,119 @@ public Accounts(OrasiDriver driver){

/**Page Interactions**/

/*
/**
* @author David Grayson
* @param document {@link String} name of the document to edit
*/
public void clickEditDocument(String document){
if (canInteract(tblDocuments)){
int row = tblDocuments.getRowWithCellText(document);
tblDocuments.findElement(By.xpath("//tr[" + row + "]//a[@class='glyphicon glyphicon-pencil']")).click();
}
}

/**
* @author David Grayson
* @param document {@link String} the name of the document to find
* @return {@link Boolean} Returns true if a document of the name provided exists in the documents table
*/
public boolean verifyDocumentExists(String document){
return tblDocuments.getRowWithCellText(document) > 0;
}

/**
* Clicks the add document button in Account or Project pages
* @author David Grayson
*/
public void clickAddDocument(){
if (canInteract(btnProjectAddDocument))
btnProjectAddDocument.click();
}

/**
* This method provides standard checks that an element can be interacted with
* @author David Grayson
* @param element {@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 element) {
return element.syncEnabled(5) && element.syncVisible(5);
}

/**
* @author David Grayson
* @param strAccount {@link String} name of Roles parent account
* @param strProject {@link String} name of Roles parent project
* @param strRole {@link String} name of role
* @return {@link Boolean} Returns <code>true</code> if the provided Roles page is loaded, <code>false</code> otherwise.
*/
public boolean verifyRolePageIsLoaded(String strAccount, String strProject, String strRole){
return PageLoaded.isElementLoaded(this.getClass(),driver,elmRoleInfoPanelHeader,5)
&& driver.findElement(By.xpath("//div[@class='breadcrumbs']")).getText()
.equals("Accounts - " + strAccount + " - " + strProject + " - " + strRole);
}

/**
* @author David Grayson
* @param strAccount {@link String} name of Projects parent account
* @param strProject {@link String} name of project
* @return {@link Boolean} Returns <code>true</code> if the provided Projects page is loaded, <code>false</code> otherwise.
*/
public boolean verifyProjectPageIsLoaded(String strAccount, String strProject){
return PageLoaded.isElementLoaded(this.getClass(),driver, elmProjectInfoPanelHeader,5)
&& driver.findElement(By.xpath("//div[@class='breadcrumbs']")).getText()
.equals("Accounts - " + strAccount + " - " + strProject);
}

/**
* @author David Grayson
* @param strAccount {@link String} name of Account
* @return {@link Boolean} Returns <code>true</code> if the provided Accounts page is loaded, <code>false</code> otherwise.
*/
public boolean verifyAccountPageIsLoaded(String strAccount){
String xpath = "//div[@class='breadcrumbs']/a[contains(text(),'" + strAccount + "')]";
return PageLoaded.isElementLoaded(this.getClass(),driver,tblProjects,5)
&& driver.findLink(By.xpath(xpath)).syncVisible(5,false);
}

/**
* @author David Grayson
* @return {@link Boolean} Returns <code>true</code> if the Accounts table is loaded, <code>false</code> otherwise.
*/
public boolean verifyAccountsPageIsLoaded(){
return PageLoaded.isElementLoaded(this.getClass(),driver,tblAccounts,5);
}

/**
* @author David Grayson
* @return {@link Boolean} Returns <code>true</code> if the rate field from the Rates table on a Project page
* matches the rate on the Rates table on the Role page.
*/
public boolean verifyRoleRate(String rate) {
TestReporter.log(driver.findElement(By.xpath("//div[@class='breadcrumbs']")).getText());
return tblRoleRates.syncVisible() && tblRoleRates.getRowWithCellText(rate, 5, 1, true) != 0;
}

/**
* Gets the rate field in the Role Table on a project page
* @author David Grayson
* @param role {@link String}the name of the role to get the rate for
* @return {@link String}
*/
public String getRoleRateFromProjectPage(String role){
final int colPosition = 2;
if (tblProjectRoles.syncEnabled(5,false) && tblProjectRoles.syncVisible(5,false)){
int row = tblProjectRoles.getRowWithCellText(role);
if (tblProjectRoles.getCell(row,colPosition).isEnabled() && tblProjectRoles.getCell(row,colPosition).isDisplayed())
return tblProjectRoles.getCell(row, colPosition).getText();
}
return "";
}

/**
* Click on accounts tab
* Make sure that the correct page loads
* author: Daniel Smith
* @author: Daniel Smith
*/
public void click_accounts_tab(String username)
{
Expand Down Expand Up @@ -116,9 +218,9 @@ public Integer getNumberOfAccounts() {

}

/*
/**
* Change the number showing for accounts per page to 100
* author: Daniel Smith
* @author: Daniel Smith
*/
public void accountsPerPage()
{
Expand All @@ -137,7 +239,7 @@ public void accountsPerPage()

}

/*
/**
* Sort accounts table by industry
* @author: Daniel Smith
*/
Expand All @@ -157,6 +259,7 @@ public void clickAccountLink(String strAccount){
String xpathExpression;
xpathExpression = "//td//a[contains(text(),'" + strAccount + "')]";
Link lnkAccount = driver.findLink(By.xpath(xpathExpression));
lnkAccount.syncVisible();
lnkAccount.click();
}

Expand Down
101 changes: 101 additions & 0 deletions src/main/java/com/orasi/bluesource/AddDocumentForm.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.Button;
import com.orasi.web.webelements.Checkbox;
import com.orasi.web.webelements.Element;
import com.orasi.web.webelements.Textbox;
import com.orasi.web.webelements.impl.internal.ElementFactory;
import org.openqa.selenium.support.FindBy;

import java.text.DecimalFormat;
import java.util.List;

public class AddDocumentForm {
private OrasiDriver driver = null;

/**Page Elements**/
@FindBy(xpath = "//form[@id='new_document']") private Element elmAddDocumentForm;
@FindBy(xpath = "//input[@name='document[file]']") private Element elmDocumentFile;
@FindBy(xpath = "//span[@class='select2-results']/ul/li") private List<Element> elmDocumentTypeOptions;
@FindBy(xpath = "//input[@id='document_budget']") private Textbox txtTotalBudget;
@FindBy(xpath = "//input[@id='document_hours']") private Textbox txtTotalHours;
@FindBy(xpath = "//input[@id='document_signed']") private Checkbox chkSigned;
@FindBy(xpath = "//input[@value='Create Document']") private Element elmCreateDocument;
@FindBy(xpath = "//form[@id='new_document']//span[@role='combobox']") private Element elmDocumentType;
@FindBy(xpath = "//input[@id='document_name']") private Textbox txtDocumentName;

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

/**Page Interactions**/

public boolean verifyFormLoaded(){
return PageLoaded.isElementLoaded(this.getClass(),driver,elmAddDocumentForm,5);
}

/**
* @author David Grayson
* @param filePath {@link String} the complete path for the file to be uploaded
*/
public void setFile(String filePath){
if (canInteract(elmDocumentFile))
elmDocumentFile.sendKeys(filePath);
}

public String getDocumentName(){
return txtDocumentName.getText();
}

public void clickCreateDocument(){
if (canInteract(elmCreateDocument))
elmCreateDocument.click();
}

public void selectDocumentType(String type){
if (canInteract(elmDocumentType)){
elmDocumentType.click();
for (Element elm:elmDocumentTypeOptions){
if (elm.getText().equals(type)){
elm.click();
break;
}
}
}
}

public void setTotalHours(double hours){
if (canInteract(txtTotalHours)){
txtTotalHours.clear();
txtTotalHours.sendKeys(new DecimalFormat("####.00").format(hours));
}
}

public void setTotalBudget(int budget){
if (canInteract(txtTotalBudget)){
txtTotalBudget.clear();
txtTotalBudget.sendKeys(String.valueOf(budget));
}
}

public void checkSigned(){
if (canInteract(chkSigned))
chkSigned.check();
}

/**
* 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);
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/orasi/bluesource/Header.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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
Loading