From f7e72ea3d259d5f031649d0b11f6d33e3be2bd3f Mon Sep 17 00:00:00 2001 From: Panika-cgi Date: Tue, 26 Nov 2024 09:54:15 -0800 Subject: [PATCH 1/2] Added test for Create Funding envelope change request through the funding tile. --- .../PortalFundingAllocationTab.java | 38 +++++++++ .../PortalFundingEnvelopeChangeRequest.java | 76 ++++++++++++++++++ .../PageFactory_Portal/PortalFundingPage.java | 47 +++++++++++ ...talCreateFundingEnvelopeChangeRequest.java | 79 +++++++++++++++++++ 4 files changed, 240 insertions(+) create mode 100644 selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingAllocationTab.java create mode 100644 selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingEnvelopeChangeRequest.java create mode 100644 selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingPage.java create mode 100644 selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/tests/portal/PortalCreateFundingEnvelopeChangeRequest.java diff --git a/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingAllocationTab.java b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingAllocationTab.java new file mode 100644 index 00000000..ae4444c9 --- /dev/null +++ b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingAllocationTab.java @@ -0,0 +1,38 @@ +package ca.bc.gov.ecc.ofm.selenium.v1.PageFactory_Portal; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.time.Duration; + +public class PortalFundingAllocationTab{ + private WebDriver driver; + WebDriverWait wait; + + @FindBy(xpath = "//body/div[@id='app']/div[@id='app']/div[1]/main[1]/div[2]/div[1]/div[3]/div[1]/div[1]/div[3]/div[1]/div[2]/button[1]/span[3]/span[1]") + @CacheLookup + private WebElement requestToReallocateFunds ; + + public PortalFundingAllocationTab(WebDriver driver) { + this.driver = driver; + PageFactory.initElements(driver, this); + wait = new WebDriverWait(driver, Duration.ofMillis(10000)); + } + + + public void ClickReallocateFunds() throws InterruptedException { + try { + wait.until(ExpectedConditions.visibilityOf(requestToReallocateFunds)); + wait.until(ExpectedConditions.elementToBeClickable(requestToReallocateFunds)).click(); + } + catch(Exception e) { + System.out.println("Request to Re-allocate funds button is not available"); + driver.quit(); + } + } +} diff --git a/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingEnvelopeChangeRequest.java b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingEnvelopeChangeRequest.java new file mode 100644 index 00000000..014b834d --- /dev/null +++ b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingEnvelopeChangeRequest.java @@ -0,0 +1,76 @@ +package ca.bc.gov.ecc.ofm.selenium.v1.PageFactory_Portal; + +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.time.Duration; + +public class PortalFundingEnvelopeChangeRequest { + private WebDriver driver; + WebDriverWait wait; + + @FindBy(id = "add-new-file") + @CacheLookup + private WebElement addNewFileButton; + + @FindBy(id = "submit-new-request") + @CacheLookup + private WebElement submitNewRequestButton; + + @FindBy(id = "selectFacility") + @CacheLookup + private WebElement selectFacilityField; + + @FindBy(xpath = "//input[@placeholder='Brief summary of request']") + @CacheLookup + private WebElement summary; + + @FindBy(xpath = "//textarea[@placeholder='Detailed description of request']") + @CacheLookup + private WebElement requestDescription; + + @FindBy(xpath = "//input[@type='file']") + @CacheLookup + private WebElement addFile; + + @FindBy(xpath= "//input[@placeholder='Enter a description (Optional)']") + @CacheLookup + private WebElement description; + + public PortalFundingEnvelopeChangeRequest(WebDriver driver) { + this.driver = driver; + PageFactory.initElements(driver, this); + wait = new WebDriverWait(driver, Duration.ofMillis(10000)); + } + + private final String filePath = System.getProperty("user.dir") + "/src/test/resources/testFile.jpg"; + + public void setSummaryTextField(String summaryValue) { + summary.sendKeys(summaryValue); + + } + + public void setRequestDescriptionTextField(String requestDescriptionValue) { + requestDescription.sendKeys(requestDescriptionValue); + } + + public void addFacility(String facility) { + selectFacilityField.sendKeys(facility); + } + + public void addNewFile() { + ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", addNewFileButton); + addFile.sendKeys(filePath); + description.sendKeys("Funding Envelope Change Request file"); + } + + public void clickSubmitNewRequest() { + submitNewRequestButton.click(); + } + +} diff --git a/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingPage.java b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingPage.java new file mode 100644 index 00000000..b2b96cdf --- /dev/null +++ b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingPage.java @@ -0,0 +1,47 @@ +package ca.bc.gov.ecc.ofm.selenium.v1.PageFactory_Portal; + +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.time.Duration; + +public class PortalFundingPage { + + private WebDriver driver; + WebDriverWait wait; + + + @FindBy(xpath = "//strong[contains(text(),'Funding Agreements')]") + @CacheLookup + private WebElement fundingAgreementsTab; + + @FindBy(xpath = "//strong[contains(text(),'Payment Records')]") + @CacheLookup + private WebElement paymentRecordsTab; + + @FindBy(xpath = "//strong[contains(text(),'Funding Allocation')]") + @CacheLookup + private WebElement fundingAllocationTab; + + public PortalFundingPage(WebDriver driver) { + this.driver = driver; + PageFactory.initElements(driver, this); + wait = new WebDriverWait(driver, Duration.ofMillis(10000)); + } + + public void clickOnFundingAgreementsTab() { + wait.until(ExpectedConditions.elementToBeClickable(fundingAgreementsTab)).click(); + } + public void clickOnPaymentRecordsTab() {; + wait.until(ExpectedConditions.elementToBeClickable(paymentRecordsTab)).click(); + } + public void clickOnFundingAllocationTab() { + wait.until(ExpectedConditions.elementToBeClickable(fundingAllocationTab)).click(); + } + +} diff --git a/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/tests/portal/PortalCreateFundingEnvelopeChangeRequest.java b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/tests/portal/PortalCreateFundingEnvelopeChangeRequest.java new file mode 100644 index 00000000..2bc77ede --- /dev/null +++ b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/tests/portal/PortalCreateFundingEnvelopeChangeRequest.java @@ -0,0 +1,79 @@ +package ca.bc.gov.ecc.ofm.selenium.v1.tests.portal; + +import ca.bc.gov.ecc.ofm.selenium.v1.PageFactory_Portal.*; +import ca.bc.gov.ecc.ofm.selenium.v1.tests.BaseTest; +import io.github.bonigarcia.wdm.WebDriverManager; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; +import org.testng.Assert; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +public class PortalCreateFundingEnvelopeChangeRequest extends BaseTest { + WebDriver driver; + + @BeforeTest + public void initDriver() { + ChromeOptions options = new ChromeOptions(); + WebDriverManager.chromedriver().setup(); + driver = new ChromeDriver(options); + driver.manage().window().maximize(); + } + + + @Test + public void CreateFundingEnvelopeChangeRequest() throws InterruptedException { + try { + driver.get(QA_PORTAL_URL); + //test = extent.createTest("Test - Create Funding Envelope Change Request"); + test.info("Starting Test - Create Funding Envelope Change Request"); + + PortalSignInFirstPage objPortalSigninFirstPage = new PortalSignInFirstPage(driver); + Thread.sleep(3000); + objPortalSigninFirstPage.clickOnBCeIdLogin(); + + PortalSignInCredentialPage objPortalSignInCredentialPage = new PortalSignInCredentialPage(driver); + objPortalSignInCredentialPage.enterUserId(QA_PORTAL_USERNAME); + objPortalSignInCredentialPage.enterPassword(QA_PORTAL_PASSWORD); + objPortalSignInCredentialPage.clickSubmit(); + objPortalSignInCredentialPage.clickSignatureRequired(); + test.info("Login complete"); + + PortalHomePage objPortalHomePage = new PortalHomePage(driver); + objPortalHomePage.clickFundingTile(); + PortalFundingPage portalFundingPage = new PortalFundingPage(driver); + test.info("Homepage complete,Landed on Funding Page"); + + Thread.sleep(5000); + portalFundingPage.clickOnFundingAllocationTab(); + PortalFundingAllocationTab portalFundingAllocationTab =new PortalFundingAllocationTab(driver); + portalFundingAllocationTab.ClickReallocateFunds(); + PortalFundingEnvelopeChangeRequest portalFundingEnvelopeChangeRequest = new PortalFundingEnvelopeChangeRequest(driver); + + portalFundingEnvelopeChangeRequest.setSummaryTextField("Funding Envelope Change Request test"); + portalFundingEnvelopeChangeRequest.addFacility("jpan"); + portalFundingEnvelopeChangeRequest.setRequestDescriptionTextField("This is a test Funding envelope change request application."); + portalFundingEnvelopeChangeRequest.addNewFile(); + portalFundingEnvelopeChangeRequest.clickSubmitNewRequest(); + + test.info("Request complete and submitted"); + + test.pass("Testcase passed!"); + } + + catch (Exception e) { + test.fail("testcase failed!"); + Assert.fail("testcase failed!"); + e.printStackTrace(); + } + } + + @AfterTest + public void tearDown() { + driver.quit(); + } +} + + From 9a89763459655882510c1dfc408ec3e536fd7270 Mon Sep 17 00:00:00 2001 From: Panika-cgi Date: Tue, 26 Nov 2024 10:07:12 -0800 Subject: [PATCH 2/2] Fixed changes as suggested. --- .../v1/PageFactory_Portal/PortalFundingAllocationTab.java | 1 - .../PageFactory_Portal/PortalFundingEnvelopeChangeRequest.java | 1 - .../tests/portal/PortalCreateFundingEnvelopeChangeRequest.java | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingAllocationTab.java b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingAllocationTab.java index ae4444c9..7415fc7b 100644 --- a/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingAllocationTab.java +++ b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingAllocationTab.java @@ -27,7 +27,6 @@ public PortalFundingAllocationTab(WebDriver driver) { public void ClickReallocateFunds() throws InterruptedException { try { - wait.until(ExpectedConditions.visibilityOf(requestToReallocateFunds)); wait.until(ExpectedConditions.elementToBeClickable(requestToReallocateFunds)).click(); } catch(Exception e) { diff --git a/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingEnvelopeChangeRequest.java b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingEnvelopeChangeRequest.java index 014b834d..763d5f3f 100644 --- a/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingEnvelopeChangeRequest.java +++ b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingEnvelopeChangeRequest.java @@ -52,7 +52,6 @@ public PortalFundingEnvelopeChangeRequest(WebDriver driver) { public void setSummaryTextField(String summaryValue) { summary.sendKeys(summaryValue); - } public void setRequestDescriptionTextField(String requestDescriptionValue) { diff --git a/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/tests/portal/PortalCreateFundingEnvelopeChangeRequest.java b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/tests/portal/PortalCreateFundingEnvelopeChangeRequest.java index 2bc77ede..43981ef1 100644 --- a/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/tests/portal/PortalCreateFundingEnvelopeChangeRequest.java +++ b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/tests/portal/PortalCreateFundingEnvelopeChangeRequest.java @@ -27,7 +27,7 @@ public void initDriver() { public void CreateFundingEnvelopeChangeRequest() throws InterruptedException { try { driver.get(QA_PORTAL_URL); - //test = extent.createTest("Test - Create Funding Envelope Change Request"); + test = extent.createTest("Test - Create Funding Envelope Change Request"); test.info("Starting Test - Create Funding Envelope Change Request"); PortalSignInFirstPage objPortalSigninFirstPage = new PortalSignInFirstPage(driver);