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
Binary file added drivers/chromedriver.exe
Binary file not shown.
152 changes: 146 additions & 6 deletions src/main/java/com/orasi/bluesource/EmployeePage.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.orasi.bluesource;

import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;

import com.orasi.web.OrasiDriver;
import com.orasi.web.webelements.Button;
import com.orasi.web.webelements.Checkbox;
import com.orasi.web.webelements.Element;
import com.orasi.web.webelements.Label;
import com.orasi.web.webelements.Textbox;
import com.orasi.web.webelements.Webtable;
Expand All @@ -17,9 +19,18 @@ public class EmployeePage {
/**Page Elements**/
@FindBy(xpath = "//tr[1]//a[@class='glyphicon glyphicon-pencil']") Button btnEditFirstProject;
@FindBy(xpath = "//div[@id='panel_body_1']//table") Webtable tblProjectInfo;
@FindBy(xpath = "//button[@data-target='#modal_1']") Button btnEditGeneral;
@FindBy(xpath = "//div//a[contains(text(),'Deactivate Employee')]") Button btnDeactivateEmployee;
@FindBy(xpath = "//div[@class='panel-heading']//a[contains(text(),'Deactivate')]") Button btnDeactivate;
@FindBy(xpath = "//*[@id=\'accordion\']/div/div[7]/button") Button btnEditGeneral;
@FindBy(xpath = "//*[@id='content']/h1") Label lblEmployeeNameHeader;
@FindBy(xpath = "//a[contains(text(),'Deactivate Employee')]") Button btnDeactivateEmployee;
@FindBy(xpath = "//a[contains(text(),'Deactivate')]") Button btnDeactivate;
@FindBy(xpath = "//*[@id=\"panel_body_1\"]/div/ul/li") Label lblDeactivateWarningMessage;
@FindBy(xpath = "//*[@id=\"select2-employee_manager_id-container\"]") Textbox txtEmployeeManager;
@FindBy(xpath = "//*[@id='panel_body_1']/div/ul[1]/li/div") Label lblDeactivateActiveWarnings;
@FindBy(xpath = "//*[@id='accordion']/div/div[5]/div[1]/a") Button btnManageTimeOff;
@FindBy(xpath = "//tr[@class='vacation-row']") Label lblFirstTimeOffOnTable;
@FindBy(xpath = "//td[contains(text(),'Status:')]/../td[2]") Label lblEmployeeStatus;
@FindBy(xpath = "//tr[@class='vacation-row']/td[3]/span") Label lblFirstTimeOffEndDate;


/**Constructor**/
public EmployeePage(OrasiDriver driver){
Expand Down Expand Up @@ -59,16 +70,145 @@ public boolean verifyStartDate(String strStartDate, String strProject) {
}

public void editGeneralInfo() {
btnEditGeneral.syncVisible(3, true);
btnEditGeneral.click();

}

public void clickDeactivateEmployee() {
btnDeactivateEmployee.syncVisible(2, true);
btnDeactivateEmployee.click();
}

public void clickDeactivate(){
btnDeactivate.syncVisible(2, true);
btnDeactivate.click();
}

/**
* Checks that the employee page you are currently on is for the
* employee you pass
* @param fullName - Name of employee you wish to check for
* @return - True if the name on the page matchs the passed value
*/
public boolean verifyEmployeePage(String fullName) {
return lblEmployeeNameHeader.getText().equalsIgnoreCase(fullName);
}

public boolean verifyDeactivateEmployeesButton() {
return btnDeactivateEmployee.syncVisible(2,true);
}

public boolean verifyDeactivateButton() {
return btnDeactivate.syncVisible(2,true);
}

public boolean verifyEmployeesLoseManagerMessage() {
return lblDeactivateWarningMessage.syncVisible(2,true);
}

/**
* This method returns the name of the employee that will be
* left without a manager due to the deactivation message
* @return - The name of the employee
*/
public String getEmployeeLosingmanager() {
return lblDeactivateWarningMessage.getText().substring(0, lblDeactivateWarningMessage.getText().indexOf(" will have "));
}

/**
* This method checks if the employee page currently brought up
* has a manager listed
* @return - True if no manager listed
*/
public boolean verifyManagerIsEmpty() {
return txtEmployeeManager.getAttribute("title").isEmpty();
}

/**
* This method checks if the Deactivate Button is onscreen,
* but cannot be clicked due to a manual warning.
* @return - True if Deactivate Button is onscreen but not interactable
*/
public boolean verifyInactiveDeactivateButton() {
try{
btnDeactivate.click();
}
catch(WebDriverException e) {
// This shows the Button cannot be clicked, if it could it would no longer be visible.
}
return btnDeactivate.syncVisible(2,true);
}

/**
* Checks if the error message from attempting to deactivate an employee
* correctly warns about subordinates.
* @return - True if the warning message matchs what it should
*/
public boolean verifyActiveDeactivateMessage() {
return lblDeactivateActiveWarnings.getText().substring(lblDeactivateActiveWarnings.getText().indexOf(' ',
lblDeactivateActiveWarnings.getText().indexOf(' ')+1)).equalsIgnoreCase(" must be reassigned to another manager.");
}

/**
* This method verifies a message is displayed when the mouse hovers over
* the inactive deactivate button (due to manual warnings)
* @return - True if Deactivate button is onscreen but no interactable
*/
public boolean verifyDeactiveButtonMessage() {
Actions action = driver.actions();
action.moveToElement(driver.findElement(By.xpath("//a[contains(text(),'Deactivate')]"))).build().perform();
return driver.findLabel(By.xpath("//div[@class='tooltip fade top in']")).syncInFrame(2,true);
}

/**
* Checks if the warning message displays the time off
* request that will be deleted.
* @return - True if the warning message is correct
*/
public boolean verifyEmployeesVacationDeactivation() {
boolean checker = false;
if(lblDeactivateWarningMessage.getText().contains(" from ") && lblDeactivateWarningMessage.getText().contains(" will be deleted."))
checker=true;
return checker;
}

public void clickManageTimeOff() {
btnManageTimeOff.syncVisible(2, true);
btnManageTimeOff.click();
}

/**
* Verifies there is no time off listed for the employee
* @return - True if no time off
*/
public boolean verifyNoTimeOff() {
boolean checker = false;
try {
lblFirstTimeOffOnTable.isDisplayed();
}
catch(NoSuchElementException e) {
checker = true;
}
return checker;
}

/**
* Checks for a specified status on the employee page
* (Active, Permanent, Contractor)
* @param status - String of the status to check for
* @return - True if the status matchs
*/
public boolean verifyEmployeeStatus(String status) {
return lblEmployeeStatus.getText().equalsIgnoreCase(status);
}

/**
* Verifies the first time off listed for an employee has
* the correct (passed) end date listed
* @param endDate - In form "Month DD, YYYY"
* @return - True if the end date on the form matchs the passed
*/
public boolean verifyFirstTimeOffEndDate(String endDate) {
return lblFirstTimeOffEndDate.getText().equalsIgnoreCase(endDate);
}
}
20 changes: 13 additions & 7 deletions src/main/java/com/orasi/bluesource/Employees.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
import java.util.ResourceBundle;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.support.FindBy;

import com.orasi.utils.Constants;
import com.orasi.utils.Sleeper;
import com.orasi.utils.TestReporter;
import com.orasi.utils.dataHelpers.personFactory.Person;
import com.orasi.web.OrasiDriver;
import com.orasi.web.PageLoaded;
import com.orasi.web.exceptions.OptionNotInListboxException;
import com.orasi.web.webelements.Button;
import com.orasi.web.webelements.Element;
import com.orasi.web.webelements.Label;
import com.orasi.web.webelements.Link;
import com.orasi.web.webelements.Listbox;
Expand Down Expand Up @@ -55,8 +52,10 @@ public void employeeSearch(String strSearch){
* @author Paul
*/
public void clickAddEmployee() {
btnAdd.syncEnabled(5,true);
btnAdd.click();
btnAdd.syncVisible(2,true);
btnAdd.syncEnabled(2,true);
btnAdd.syncInFrame(2,true);
btnAdd.click();
}

/**
Expand Down Expand Up @@ -309,7 +308,14 @@ public boolean checkAccountPermissionOption(String strOption) {
catch (OptionNotInListboxException e){
return false;
}


}
/**
* This method checks if the employee searchbar is on the screen
* @return - True if the employee search bar is visible
* @author Andrew McGrail
*/
public boolean verifyEmployeeSearchExists() {
return txtEmployeeSearch.syncVisible(2,true);
}

}
9 changes: 6 additions & 3 deletions src/main/java/com/orasi/bluesource/Header.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ else if (accountBool == false)
* @author Paul
*/
public void navigateEmployees() {
MessageCenter messageCenter = new MessageCenter(driver);
messageCenter.closeMessageCenter();
lnkEmployees.click();
lnkEmployees.syncVisible(2,true);
// MessageCenter messageCenter = new MessageCenter(driver);
// messageCenter.closeMessageCenter();
lnkEmployees.syncVisible(2,true);
lnkEmployees.syncInFrame(2,true);
lnkEmployees.click();
}

public void navigateProjectEmployees() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Tests Deactivate Employee_Active Employees_Issue462 & 940
* This test checks when a manager of an active subordinate is
* made inactive the system requires a manual change of manager
* and disallows the deactivation
* @author Andrew McGrail
*/

package com.bluesource.employees;

import com.orasi.utils.TestReporter;

import org.testng.ITestContext;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import com.orasi.bluesource.EmployeePage;
import com.orasi.bluesource.Employees;
import com.orasi.bluesource.LoginPage;
import com.orasi.web.WebBaseTest;

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

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

@Test
public void testDeactivateEmployeeActiveEmployees()
{
String firstName = "HasActive";
String lastName = "Subordinates";
String fullName = firstName+" "+lastName;

LoginPage loginPage = new LoginPage(getDriver());
Employees employees = new Employees(getDriver());
EmployeePage employeePage = new EmployeePage(getDriver());

// Step 1 Preconditions: Identify or create a user that has active and inactive subordinates
// Employee: HasActive Subordinates
// Step 2 Open browser.
// Step 3 Navigate to http://10.238.242.236
// Step 4 Enter a valid username of a user with one of the following roles: Company Admin, Department Admin, department Head, Upper management
// Step 5 Enter a valid password.
// Step 6 Click the Login button or press Enter.
loginPage.AdminLogin();
// Step 7 Click an employee name.
employees.employeeSearch(fullName);
employees.selectEmployeeByName(firstName);
TestReporter.assertTrue(employeePage.verifyEmployeePage(fullName), "Successfully landed on "+fullName+"'s employee page");
// Step 8 Click the Edit button in the General Info section.
employeePage.editGeneralInfo();
TestReporter.assertTrue(employeePage.verifyDeactivateEmployeesButton(), fullName+"'s edit general modal has been brought up");
// Step 9 Verify the Deactivate Employee button is displayed at the bottom of the window.
TestReporter.assertTrue(employeePage.verifyDeactivateEmployeesButton(), "The edit general modal has a Deactivate Employee Button");
// Step 10 Click the Deactivate Employee button.
employeePage.clickDeactivateEmployee();
TestReporter.assertTrue(employeePage.verifyDeactivateButton(), "The Deactivate Employee Button was pushed");
// Step 11 Verify the Deactivate button is displayed and greyed out at the top right of the page.
TestReporter.assertTrue(employeePage.verifyInactiveDeactivateButton(), "The Deactivate Button is on the page and cannot be interacted with");
// Step 12 Verify the text under 'Manual Actions' is displayed as a list of the employee's active subordinates: "(Employee) must be reassigned to another manager."
TestReporter.assertTrue(employeePage.verifyActiveDeactivateMessage(), "Verified the manual actions warning message");
// Step 13 Hover over the 'Deactivate' button and verify there is a message you cannot deactivate employee until all manual actions are resolved.
TestReporter.assertTrue(employeePage.verifyDeactiveButtonMessage(), "The deactivate button displas a message when hovered over");
}
}
Loading