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..7415fc7b --- /dev/null +++ b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingAllocationTab.java @@ -0,0 +1,37 @@ +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.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..763d5f3f --- /dev/null +++ b/selenium-testing/src/test/java/ca/bc/gov/ecc/ofm/selenium/v1/PageFactory_Portal/PortalFundingEnvelopeChangeRequest.java @@ -0,0 +1,75 @@ +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..43981ef1 --- /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(); + } +} + +