From d28100f1125cc7586482603b61bfcce2198f0ef9 Mon Sep 17 00:00:00 2001 From: pallavi yewale <157051417+pallaviyewaleDefra@users.noreply.github.com> Date: Mon, 20 Jan 2025 22:43:53 +0000 Subject: [PATCH] CP Cross browser pipeline --- CP-pipeline-crossbrowserAndroid.yml | 13 +------ CP-pipeline-crossbrowserIOS.yml | 13 +------ CP-pipeline-crossbrowserMacOS.yml | 12 ------ CP-pipeline-crossbrowserWindows.yml | 13 +------ .../CP/CPRouteCheckingValidation.feature | 4 +- .../Pages/CP/Pages/RouteCheckingPage.cs | 16 +++++--- .../Pages/CP/Pages/SignInCPPage.cs | 37 ++++++++++++++---- .../Pages/CP/Pages/WelcomePage.cs | 39 +++++++++++++++---- 8 files changed, 78 insertions(+), 69 deletions(-) diff --git a/CP-pipeline-crossbrowserAndroid.yml b/CP-pipeline-crossbrowserAndroid.yml index 2190197..67ff60f 100644 --- a/CP-pipeline-crossbrowserAndroid.yml +++ b/CP-pipeline-crossbrowserAndroid.yml @@ -26,18 +26,7 @@ parameters: type: string default: 'Edge' -schedules: -- cron: "0 16 * * Mon,Tue,Wed,Thu,Fri" - displayName: Daily CrossBrowser build - branches: - include: - - dev - exclude: - - feature/* - - task/* - - master - - + resources: repositories: - repository: clientautomationreponew diff --git a/CP-pipeline-crossbrowserIOS.yml b/CP-pipeline-crossbrowserIOS.yml index c132968..729b445 100644 --- a/CP-pipeline-crossbrowserIOS.yml +++ b/CP-pipeline-crossbrowserIOS.yml @@ -25,18 +25,7 @@ parameters: - name: Target type: string default: 'Edge' - -schedules: -- cron: "0 14 * * Mon,Tue,Wed,Thu,Fri" - displayName: Daily CrossBrowser build - branches: - include: - - dev - exclude: - - feature/* - - task/* - - master - + resources: repositories: diff --git a/CP-pipeline-crossbrowserMacOS.yml b/CP-pipeline-crossbrowserMacOS.yml index 1eb0011..d3f4ac3 100644 --- a/CP-pipeline-crossbrowserMacOS.yml +++ b/CP-pipeline-crossbrowserMacOS.yml @@ -26,18 +26,6 @@ parameters: type: string default: 'Edge' -schedules: -- cron: "0 15 * * Mon,Tue,Wed,Thu,Fri" - displayName: Daily CrossBrowser build - branches: - include: - - dev - exclude: - - feature/* - - task/* - - master - - resources: repositories: - repository: clientautomationreponew diff --git a/CP-pipeline-crossbrowserWindows.yml b/CP-pipeline-crossbrowserWindows.yml index ee0b029..800cae7 100644 --- a/CP-pipeline-crossbrowserWindows.yml +++ b/CP-pipeline-crossbrowserWindows.yml @@ -25,18 +25,7 @@ parameters: - name: Target type: string default: 'Edge' - -schedules: -- cron: "0 17 * * Mon,Tue,Wed,Thu,Fri" - displayName: Daily CrossBrowser build - branches: - include: - - dev - exclude: - - feature/* - - task/* - - master - + resources: repositories: diff --git a/nipts-pts-automation-tests/Features/CP/CPRouteCheckingValidation.feature b/nipts-pts-automation-tests/Features/CP/CPRouteCheckingValidation.feature index 58790c6..af435bc 100644 --- a/nipts-pts-automation-tests/Features/CP/CPRouteCheckingValidation.feature +++ b/nipts-pts-automation-tests/Features/CP/CPRouteCheckingValidation.feature @@ -36,7 +36,7 @@ Scenario Outline: Verify validation text for empty text box checking a flight Then I provide the '' in the box And I have provided Scheduled departure time When I click save and continue button from route checke page - Then I should see an error message "Enter the flight number you are checking" in route checking page + Then I should see an error message "Enter the flight number. For example, RK 103" in route checking page Examples: | Transportation | Flight number | | Flight | | @@ -46,7 +46,7 @@ Scenario Outline: Verify validation text for special character text box checking Then I provide the '' in the box And I have provided Scheduled departure time When I click save and continue button from route checke page - Then I should navigate to Welcome page + Then I should see an error message "Enter the flight number using up to 8 letters and numbers (for example, RK 103)" in route checking page Examples: | Transportation | FlightNumber | | Flight | $$£@lk | diff --git a/nipts-pts-automation-tests/Pages/CP/Pages/RouteCheckingPage.cs b/nipts-pts-automation-tests/Pages/CP/Pages/RouteCheckingPage.cs index c1dc65b..c543caa 100644 --- a/nipts-pts-automation-tests/Pages/CP/Pages/RouteCheckingPage.cs +++ b/nipts-pts-automation-tests/Pages/CP/Pages/RouteCheckingPage.cs @@ -45,17 +45,21 @@ public void SelectTransportationOption(string radioButtonValue) if (radioButtonValue == "Ferry") { - if (!rdoFerry.Selected) - { - rdoFerry.Click(); - } + //if (!rdoFerry.Selected) + //{ + //rdoFerry.Click(); + IJavaScriptExecutor jsExecutor = (IJavaScriptExecutor)_driver; + jsExecutor.ExecuteScript("arguments[0].click();", rdoFerry); + //} } else if (radioButtonValue == "Flight") { if (!rdoFlight.Selected) { - rdoFlight.Click(); + //rdoFlight.Click(); + IJavaScriptExecutor jsExecutor = (IJavaScriptExecutor)_driver; + jsExecutor.ExecuteScript("arguments[0].click();", rdoFlight); } } } @@ -81,6 +85,7 @@ public string SelectDropDownDepartureTime() var hour = DateTime.Now.ToString("HH"); var minutes = DateTime.Now.ToString("mm"); string departureTime = $"'{hour}':'{minutes}'"; + ((IJavaScriptExecutor)_driver).ExecuteScript("arguments[0].scrollIntoView()", hourDropdown); SelectElement selectHour = new SelectElement(hourDropdown); selectHour.SelectByValue(hour); @@ -95,6 +100,7 @@ public void SelectDropDownDepartureTimeWithSPS() var hour = DateTime.Now.ToString("HH"); var minutes = DateTime.Now.ToString("mm"); + ((IJavaScriptExecutor)_driver).ExecuteScript("arguments[0].scrollIntoView()", hourDropdown); SelectElement selectHour = new SelectElement(hourDropdown); selectHour.SelectByValue(hour); SelectElement selectMinute = new SelectElement(minuteDropdown); diff --git a/nipts-pts-automation-tests/Pages/CP/Pages/SignInCPPage.cs b/nipts-pts-automation-tests/Pages/CP/Pages/SignInCPPage.cs index 52b9366..443b32a 100644 --- a/nipts-pts-automation-tests/Pages/CP/Pages/SignInCPPage.cs +++ b/nipts-pts-automation-tests/Pages/CP/Pages/SignInCPPage.cs @@ -1,8 +1,10 @@ using BoDi; +using Defra.UI.Framework.Driver; using nipts_pts_automation_tests.Configuration; using nipts_pts_automation_tests.HelperMethods; using nipts_pts_automation_tests.Pages.CP.Interfaces; using OpenQA.Selenium; +using OpenQA.Selenium.Support.UI; using SeleniumExtras.WaitHelpers; @@ -25,10 +27,11 @@ public SignInCPPage(IObjectContainer container) private By signInConfirmBy => By.XPath("//h1[contains(@class,'govuk-heading-xl')]"); private IWebElement UserId => _driver.FindElement(By.CssSelector("#user_id")); private IWebElement Password => _driver.FindElement(By.CssSelector("#password")); - private IWebElement SignIn => _driver.WaitForElement(By.Id("continue")); + private IWebElement SignIn => _driver.WaitForElement(By.XPath("//button[contains(@id,'continue')]")); private IWebElement txtLoging => _driver.WaitForElement(By.XPath("//input[@id='password']")); private IWebElement btnContinue => _driver.WaitForElement(By.XPath("//button[normalize-space()='Continue']")); private IWebElement signOutBy => _driver.WaitForElement(By.XPath("//a[@href='/signout']//*[name()='svg']")); + private IWebElement SignOut => _driver.WaitForElement(By.XPath("//a[@href='/signout']")); #endregion #region Methods @@ -41,17 +44,24 @@ public void IsSignedIn(string userName, string password) { if (PageHeading.Text == "Sign in using Government Gateway") { + ((IJavaScriptExecutor)_driver).ExecuteScript("arguments[0].scrollIntoView()", SignIn); UserId.SendKeys(userName); Password.SendKeys(password); - _driver.WaitForElementCondition(ExpectedConditions.ElementToBeClickable(SignIn)).Click(); + //_driver.WaitForElementCondition(ExpectedConditions.ElementToBeClickable(SignIn)).Click(); + Thread.Sleep(2000); + ((IJavaScriptExecutor)_driver).ExecuteScript("arguments[0].click();", SignIn); + Thread.Sleep(2000); } } public bool IsSignedOut() { - ((IJavaScriptExecutor)_driver).ExecuteScript("arguments[0].scrollIntoView()", signOutBy); - signOutBy.Click(); + //((IJavaScriptExecutor)_driver).ExecuteScript("arguments[0].scrollIntoView()", SignOut); + //signOutBy.Click(); Thread.Sleep(1000); + IJavaScriptExecutor jsExecutor = (IJavaScriptExecutor)_driver; + jsExecutor.ExecuteScript("arguments[0].click();", SignOut); + Thread.Sleep(2000); return PageHeading.Text.Contains("You have signed out") || PageHeading.Text.Contains("Your Defra account"); } @@ -59,9 +69,22 @@ public void EnterPassword() { Thread.Sleep(1000); if(PageHeading.Text == "This is a test environment") - { - txtLoging.SendKeys(ConfigSetup.BaseConfiguration.TestConfiguration.EnvPassword); - btnContinue.Click(); + { + string envPassword = ConfigSetup.BaseConfiguration.TestConfiguration.EnvPassword; + IJavaScriptExecutor jse = (IJavaScriptExecutor)_driver; + IJavaScriptExecutor jsExecutor = (IJavaScriptExecutor)_driver; + Thread.Sleep(3000); + ((IJavaScriptExecutor)_driver).ExecuteScript("arguments[0].scrollIntoView()", btnContinue); + jsExecutor.ExecuteScript("arguments[0].click();", btnContinue); + Thread.Sleep(5000); + txtLoging.SendKeys(envPassword); + //jse.ExecuteScript("arguments[0].setAttribute('value','" + envPassword + "')", txtLoging); + Thread.Sleep(3000); + jsExecutor.ExecuteScript("arguments[0].click();", btnContinue); + Thread.Sleep(5000); + + //IAlert alert = _driver.SwitchTo().Alert(); + //alert.Dismiss(); } } #endregion diff --git a/nipts-pts-automation-tests/Pages/CP/Pages/WelcomePage.cs b/nipts-pts-automation-tests/Pages/CP/Pages/WelcomePage.cs index c40eea2..af4904b 100644 --- a/nipts-pts-automation-tests/Pages/CP/Pages/WelcomePage.cs +++ b/nipts-pts-automation-tests/Pages/CP/Pages/WelcomePage.cs @@ -1,4 +1,5 @@ using BoDi; +using nipts_pts_automation_tests.Configuration; using nipts_pts_automation_tests.HelperMethods; using nipts_pts_automation_tests.Pages.CP.Interfaces; using OpenQA.Selenium; @@ -53,12 +54,21 @@ public void clickOnView() string departureDate = ""; string departureTime = ""; string headerTime = headerDepartureTime.Text.Trim(); - string route = headerTime.Substring(7,29).Trim(); + string route = headerTime.Substring(7, 29).Trim(); if (route.Contains("Birkenhead to Belfast (Stena)")) { - departureDate = headerTime.Substring(53, 10); - departureTime = headerTime.Substring(64, 5); - departTime = headerTime.Substring(64, 5); + if (ConfigSetup.BaseConfiguration.TestConfiguration.BSBrowserVersion == "16.5") + { + departureDate = headerTime.Substring(60, 10); + departureTime = headerTime.Substring(71, 5); + departTime = headerTime.Substring(71, 5); + } + else + { + departureDate = headerTime.Substring(53, 10); + departureTime = headerTime.Substring(64, 5); + departTime = headerTime.Substring(64, 5); + } } else if (route.Contains("Cairnryan to Larne (P&O)")) { @@ -88,7 +98,14 @@ public void clickOnViewWithSPSUser(string departureRoute) string departureDate = ""; if (departureRoute.Contains("Birkenhead to Belfast (Stena)")) { - departureDate = headerTime.Substring(53, 10); + if (ConfigSetup.BaseConfiguration.TestConfiguration.BSBrowserVersion == "16.5") + { + departureDate = headerTime.Substring(60, 10); + } + else + { + departureDate = headerTime.Substring(53, 10); + } } else if (departureRoute.Contains("Cairnryan to Larne (P&O)")) { @@ -117,8 +134,16 @@ public bool DepartureDateTimeCheck() string route = headerTime.Substring(7,29).Trim(); if (route.Contains("Birkenhead to Belfast (Stena)")) { - departureDate = headerTime.Substring(53, 10); - departureTime = headerTime.Substring(64, 5); + if (ConfigSetup.BaseConfiguration.TestConfiguration.BSBrowserVersion == "16.5") + { + departureDate = headerTime.Substring(60, 10); + departureTime = headerTime.Substring(71, 5); + } + else + { + departureDate = headerTime.Substring(53, 10); + departureTime = headerTime.Substring(64, 5); + } } else if (route.Contains("Cairnryan to Larne (P&O)")) {