diff --git a/drivers/chromedriver.exe b/drivers/chromedriver.exe new file mode 100644 index 0000000..28a4067 Binary files /dev/null and b/drivers/chromedriver.exe differ diff --git a/src/main/java/com/orasi/bluesource/Admin.java b/src/main/java/com/orasi/bluesource/Admin.java new file mode 100644 index 0000000..6931a59 --- /dev/null +++ b/src/main/java/com/orasi/bluesource/Admin.java @@ -0,0 +1,131 @@ +package com.orasi.bluesource; + +import org.openqa.selenium.By; +import org.openqa.selenium.support.FindBy; + +import com.orasi.web.OrasiDriver; +import com.orasi.web.webelements.Button; +import com.orasi.web.webelements.Label; +import com.orasi.web.webelements.Textbox; +import com.orasi.web.webelements.impl.internal.ElementFactory; + +public class Admin { + private OrasiDriver driver = null; + + /**Page Elements**/ + @FindBy(xpath = "//div[@data-target='#modal_1']") Button btnAddCompany; + @FindBy(xpath = "//*[@id='modal_1']/div/div") Label lblAddCompanyModal; + @FindBy(xpath = "//*[@id='company_name']") Textbox txtCompanyName; + @FindBy(xpath = "//*[@id='company_logo']") Button btnCompanyLogo; + @FindBy(xpath = "//input[@value='Create Company']") Button btnCreateCompany; + @FindBy(xpath = "//*[@id='content']/div[3]/div[2]/table/tbody/tr[3]/td[3]/a/span") Button btnEditThirdCompany; + @FindBy(xpath = "(//*[@id='company_name'])[2]") Textbox txtEditCompanyName; + @FindBy(xpath = "//span[@class='btn btn-link change-logo']") Button btnChangeLogo; + @FindBy(xpath = "(//*[@id='company_logo'])[2]") Button btnEditCompanyLogo; + @FindBy(xpath = "//input[@value='Update Company']") Button btnUpdateCompany; + @FindBy(xpath = "//*[@id='content']/div[3]/div[2]/table/tbody/tr[3]/td[2]") Label lblThirdCompanyName; + @FindBy(xpath = "//*[@id='content']/div[3]/div[2]/table/tbody/tr[3]/td[1]/img") Label lblThirdCompanyLogo; + + /**Constructor**/ + public Admin(OrasiDriver driver){ + this.driver = driver; + ElementFactory.initElements(driver, this); + } + + /**Page Interactions**/ + + public void clickAddCompany() { + btnAddCompany.syncVisible(2,true); + btnAddCompany.click(); + } + + public boolean verifyAddCompany() { + return btnAddCompany.syncVisible(2,true); + } + + public boolean verifyAddCompanyModal() { + return lblAddCompanyModal.syncVisible(2,true); + } + + /** + * Sets the company name in the create company modal + * @param companyName - Name of company + */ + public void populateCompanyName(String companyName) { + lblAddCompanyModal.syncVisible(2,true); + txtCompanyName.sendKeys(companyName); + } + + /** + * Sets the logo path in the create company modal + * @param logoPath - Path on computer to logo + */ + public void setCompanyLogo(String logoPath) { + btnCompanyLogo.sendKeys(logoPath); + } + + public void clickCreateCompany() { + lblAddCompanyModal.syncVisible(2,true); + btnCreateCompany.click(); + } + + /** + * Attempts to check the list of companies for a specified name and logo + * @param companyName - Name of company to check for + * @param logoName - Name of logo to check for + * @return - True if both exist + */ + public boolean verifyCreatedCompanyNameLogo(String companyName, String logoName) { + boolean checker = false; + if(driver.findLabel(By.xpath("//td[contains(text(),'"+companyName+"')]")).getText().equalsIgnoreCase(companyName) + && driver.findLabel(By.xpath("//img[@alt='"+logoName+"']")).syncVisible(1)) + checker = true; + return checker; + } + + public void clickEditThirdCompany() { + btnEditThirdCompany.syncVisible(2,true); + btnEditThirdCompany.click(); + } + + /** + * Updates the Edit Company modal to the passed logo + * @param logoPath - Path on computer to logo file + */ + public void updateCompanyLogo(String logoPath) { + btnChangeLogo.syncVisible(2,true); + btnChangeLogo.click(); + btnEditCompanyLogo.sendKeys(logoPath); + } + + public void clickUpdateCompany() { + btnUpdateCompany.click(); + } + + /** + * Updates the Edit Company modal to the passed name + * @param newCompanyName - Name to be changed to + */ + public void updateCompanyName(String newCompanyName) { + txtEditCompanyName.syncVisible(2,true); + txtEditCompanyName.set(newCompanyName); + } + + /** + * Verifies the name of the third company is the company name passed + * @param companyName - Name of the company + * @return - True if they match + */ + public boolean verifyThirdCompanyName(String companyName) { + return lblThirdCompanyName.getText().equalsIgnoreCase(companyName); + } + + /** + * Verifies the logo of the third company is the logo name passed + * @param logoName - Name of the logo + * @return - True if they match + */ + public boolean verifyThirdCompanyLogo(String logoName) { + return lblThirdCompanyLogo.getAttribute("alt").equalsIgnoreCase(logoName); + } +} \ No newline at end of file diff --git a/src/main/java/com/orasi/bluesource/EmployeePage.java b/src/main/java/com/orasi/bluesource/EmployeePage.java index 2cf3f9b..3ac1f65 100644 --- a/src/main/java/com/orasi/bluesource/EmployeePage.java +++ b/src/main/java/com/orasi/bluesource/EmployeePage.java @@ -7,6 +7,7 @@ import com.orasi.web.webelements.Checkbox; import com.orasi.web.webelements.Element; import com.orasi.web.webelements.Label; +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; @@ -17,9 +18,9 @@ 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(partialLinkText = "Deactivate Employee") Button btnDeactivateEmployee; + @FindBy(partialLinkText = "Deactivate") Button btnDeactivate; /**Constructor**/ public EmployeePage(OrasiDriver driver){ @@ -59,15 +60,18 @@ 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(){ + btnDeactivateEmployee.syncVisible(2, true); btnDeactivate.click(); } diff --git a/src/main/java/com/orasi/bluesource/Employees.java b/src/main/java/com/orasi/bluesource/Employees.java index 4f7c74d..f53f210 100644 --- a/src/main/java/com/orasi/bluesource/Employees.java +++ b/src/main/java/com/orasi/bluesource/Employees.java @@ -55,8 +55,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(); } /** @@ -309,7 +311,7 @@ public boolean checkAccountPermissionOption(String strOption) { catch (OptionNotInListboxException e){ return false; } - + } - + } \ No newline at end of file diff --git a/src/main/java/com/orasi/bluesource/Header.java b/src/main/java/com/orasi/bluesource/Header.java index 1c09b5a..fd1ee63 100644 --- a/src/main/java/com/orasi/bluesource/Header.java +++ b/src/main/java/com/orasi/bluesource/Header.java @@ -6,6 +6,7 @@ import org.openqa.selenium.support.FindBy; import com.orasi.web.OrasiDriver; +import com.orasi.web.webelements.Button; import com.orasi.web.webelements.Link; import com.orasi.web.webelements.impl.internal.ElementFactory; @@ -18,8 +19,8 @@ public class Header { @FindBy(xpath = "//li[contains(.,'Employees')]/a") private Link lnkEmployees; @FindBy(xpath = "//a[contains(text(),'Project')]") private Link lnkProjemployees; @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; + @FindBy(xpath = "/html/body/header/div/nav/ul/li[2]/a") private Button btnAdminDropdown; + @FindBy(xpath = "//a[contains(text(),'Companies')]") private Link lnkCompanies; /**Constructor**/ public Header(OrasiDriver driver){ @@ -64,9 +65,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() { @@ -83,10 +87,9 @@ public void navigateLogout() { lnkLogout.click(); } - public void navigateTimesheetLocks() { - MessageCenter messageCenter = new MessageCenter(driver); - messageCenter.closeMessageCenter(); - lnkAdmin.click(); - lnkTimesheetLocks.click(); + public void navigateCompanies() { + btnAdminDropdown.click(); + lnkCompanies.syncVisible(2,true); + lnkCompanies.click(); } } \ No newline at end of file diff --git a/src/test/java/com/bluesource/CompanyAdminAdminCompanies.java b/src/test/java/com/bluesource/CompanyAdminAdminCompanies.java new file mode 100644 index 0000000..a1498d3 --- /dev/null +++ b/src/test/java/com/bluesource/CompanyAdminAdminCompanies.java @@ -0,0 +1,92 @@ +/** + * Tests Company Admin_Admin_Companies - Isse #946 & #964 + * This test creates a company with a given name and logo, + * then verifies the company was created correctly. The test + * goes on to edit a company's name and logo and verify if + * those are changed correctly + * @author andrew.mcgrail + */ +package com.bluesource; + +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.Admin; +import com.orasi.bluesource.Header; +import com.orasi.bluesource.LoginPage; +import com.orasi.utils.TestReporter; +import com.orasi.web.WebBaseTest; + +public class CompanyAdminAdminCompanies 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 testCompanyAdminAdminCompanies() + { + String logoFilePath = "C:\\Users\\andrew.mcgrail\\Desktop\\Fortnite Logo.png"; + String logoName = "Fortnite Logo"; + String logoFilePath2 = "C:\\Users\\andrew.mcgrail\\Desktop\\Skull And Crossbones Logo.png"; + String logoName2 = "Skull And Crossbones Logo"; + String companyName = "Pleasant Park Punishers"; + String companyName2 = "Retail Row Renegades"; + + LoginPage loginPage = new LoginPage(getDriver()); + Header header = new Header(getDriver()); + Admin adminPage = new Admin(getDriver()); + + // Step 1 Open the browser and navigate to "http://10.238.243.127". + // Step 2 Login as 'company.admin'. + loginPage.AdminLogin(); + // Step 3 Click on 'Admin' -> 'Companies'. + header.navigateCompanies(); + TestReporter.assertTrue(adminPage.verifyAddCompany(), "Successfully landed on Companies page"); + // Step 4 Click on the 'Add Company' button. + adminPage.clickAddCompany(); + TestReporter.assertTrue(adminPage.verifyAddCompanyModal(), "Successfully opened Add Company Modal"); + // Step 5 Type in a Name inside the 'Name' textbox. + adminPage.populateCompanyName(companyName); + // Step 6 Select an image to upload into the 'Logo' file upload field. + adminPage.setCompanyLogo(logoFilePath); + // Step 7 Click the 'Create Company' button and verify a Company is created with the Logo displaying. + adminPage.clickCreateCompany(); + TestReporter.assertTrue(adminPage.verifyCreatedCompanyNameLogo(companyName, logoName), "Verified the company "+companyName+" was created with "+logoName); + // Step 8 Click on the pencil icon to Edit one of the Companies. + adminPage.clickEditThirdCompany(); + // Step 9 Click the 'Change' link and update the Logo's file. + adminPage.updateCompanyLogo(logoFilePath2); + // Step 10 Click the 'Update Company' button and verify the Company's Logo is updated. + adminPage.clickUpdateCompany(); + TestReporter.assertTrue(adminPage.verifyThirdCompanyLogo(logoName2), "Verified the Company Logo was updated to "+logoName2); + // Step 11 Click on the pencil icon to Edit one of the Companies. + adminPage.clickEditThirdCompany(); + // Step 12 Type in another name into the 'Name' textbox. + adminPage.updateCompanyName(companyName2); + TestReporter.logStep("Updated the Company name to "+companyName2); + // Step 13 Click the 'Update Company' button and verify the Company's Name is updated. + adminPage.clickUpdateCompany(); + TestReporter.assertTrue(adminPage.verifyThirdCompanyName(companyName2), "Verified the Company name was changed to "+companyName2); + } +} \ No newline at end of file diff --git a/src/test/resources/drivers/chromedriver.exe b/src/test/resources/drivers/chromedriver.exe new file mode 100644 index 0000000..28a4067 Binary files /dev/null and b/src/test/resources/drivers/chromedriver.exe differ diff --git a/src/test/resources/sandbox.xml b/src/test/resources/sandbox.xml index d3793a8..87b3626 100644 --- a/src/test/resources/sandbox.xml +++ b/src/test/resources/sandbox.xml @@ -13,7 +13,7 @@ - +