From cf4c4d85856879a827af1b1b6c8f78affe07a98e Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Thu, 6 Mar 2025 16:15:58 -0500 Subject: [PATCH 1/6] Added url validation Changed existing validateURL function on BasePage to WaitForURL, and added a new function for checking the url of the page. Added calls to this function throughout the workflow, on each page change --- playwright-tests/pages/BasePage.ts | 6 +++- playwright-tests/pages/WelcomePage.ts | 4 +-- playwright-tests/tests/0000__M.test.ts | 45 +++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/playwright-tests/pages/BasePage.ts b/playwright-tests/pages/BasePage.ts index 711a80e6..c241c45e 100644 --- a/playwright-tests/pages/BasePage.ts +++ b/playwright-tests/pages/BasePage.ts @@ -37,7 +37,7 @@ export class BasePage { }).toPass({ timeout: 180_000 }); } - async validateURL(url: string) { + async waitForURL(url: string) { await expect(this.pageSpinner).toHaveCount(0, { timeout: 60000 }); await this.page.waitForURL(url); } @@ -115,4 +115,8 @@ export class BasePage { } + async validateURL(url: string) { + const currentUrl = this.page.url(); + expect(currentUrl).toEqual(url); + } } \ No newline at end of file diff --git a/playwright-tests/pages/WelcomePage.ts b/playwright-tests/pages/WelcomePage.ts index 1a38f9b4..8002ca56 100644 --- a/playwright-tests/pages/WelcomePage.ts +++ b/playwright-tests/pages/WelcomePage.ts @@ -35,7 +35,7 @@ export class WelcomePage extends BasePage { async goto(clientTag: string) { await this.page.goto(process.env['BASE_URL']! + `/?issPage=entry-page&ClientTag=${clientTag}`); - await this.validateURL(this.url); + await this.waitForURL(this.url); await this.cookieCloseButton.click(); } @@ -54,7 +54,7 @@ export class WelcomePage extends BasePage { } const result = await getClientSignature(request); await this.page.goto(process.env['BASE_URL']! + `/?issPage=entry-page&ClientTag=${clientTag}&token=${request.token}&signature=${result.signature}`); - await this.validateURL(this.url); + await this.waitForURL(this.url); await this.logReferralNumber(); await this.cookieCloseButton.click(); } diff --git a/playwright-tests/tests/0000__M.test.ts b/playwright-tests/tests/0000__M.test.ts index 11f110fe..5802e1a8 100644 --- a/playwright-tests/tests/0000__M.test.ts +++ b/playwright-tests/tests/0000__M.test.ts @@ -370,6 +370,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { // TODO: Dynamic for when we don't care if duplicate page appears await test.step('DuplicateCheckPage >> Start New Claim', async () => { + await duplicateCheckPage.validateURL(duplicateCheckPage.url); await duplicateCheckPage.startNewClaim(); await duplicateCheckPage.nextPage(); }); @@ -377,6 +378,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isPolicyFound) { await test.step('PolicyVehiclesPage >> Select vehicle', async () => { + await policyVehiclesPage.validateURL(policyVehiclesPage.url); await policyVehiclesPage.logReferralNumber(); // Validate other vehicles on policy if (otherVehiclesOnPolicy && otherVehiclesOnPolicy.length > 0) { @@ -398,6 +400,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isHeavyTruckVehicleBailout) { await test.step('BailoutPage >> Heavy Vehicle Bailout', async () => { + await bailoutPage.validateURL(bailoutPage.url); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.HeavyTruckVehicle); }); return; @@ -405,6 +408,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (hasEndorsements) { await test.step('EndorsementsPage >> Select Endorsements', async () => { + await endorsementsPage.validateURL(endorsementsPage.url); await endorsementsPage.verifyEndorsements(endorsements); await endorsementsPage.selectEndorsements(endorsements); await endorsementsPage.nextPage(); @@ -414,6 +418,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } else { await policyVehiclesPage.logReferralNumber(); await test.step('PolicyHolderDetailsPage >> Enter customer data', async () => { + await policyHolderDetailsPage.validateURL(policyHolderDetailsPage.url); await policyHolderDetailsPage.fillCustomerDetails(customerDetails!); await policyHolderDetailsPage.nextPage(); }); @@ -423,12 +428,14 @@ async function runWorkflow(page: Page, testCase: TestCase) { } await test.step('VehicleDetailsPage >> Select Vehicle', async () => { + await vehicleSelectionPage.validateURL(vehicleSelectionPage.url); await vehicleSelectionPage.selectVehicle(vehicleDetails!); await vehicleSelectionPage.nextPage(); }); if (isVehicleLookupBailout) { await test.step('BailoutPage >> Vehicle Lookup Bailout', async () => { + await bailoutPage.validateURL(bailoutPage.url); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.VehicleLookupError); }); return; @@ -436,6 +443,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isHeavyTruckVehicleBailout) { await test.step('BailoutPage >> Heavy Vehicle Bailout', async () => { + await bailoutPage.validateURL(bailoutPage.url); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.HeavyTruckVehicle); }); return; @@ -446,11 +454,13 @@ async function runWorkflow(page: Page, testCase: TestCase) { isPolicyFound = false; // Flow proceeds as unverified testCase.testData.isPolicyFound = false; await test.step('VehicleDamagePage >> Click Edit Vehicle', async () => { + await vehicleDamagePage.validateURL(vehicleDamagePage.url); await vehicleDamagePage.editVehicleButton.click(); }); await test.step('VehicleDetailsPage >> Select edited vehicle', async () => { await test.step('VehicleDetailsPage >> Select Vehicle', async () => { + await vehicleSelectionPage.validateURL(vehicleSelectionPage.url); await vehicleSelectionPage.selectVehicle(editVehicleDetails); await vehicleSelectionPage.nextPage(); }); @@ -458,6 +468,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } await test.step('VehicleDamagePage >> Select Damage', async () => { + await vehicleDamagePage.validateURL(vehicleDamagePage.url); if (isSeparateApptsWarning) { await vehicleDamagePage.checkSeparateApptsWarning(); } @@ -467,14 +478,17 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isPartsServiceErrorBailout) { await test.step('VehicleLookupPage >> Select Lookup Type', async () => { + await vehicleLookupPage.validateURL(vehicleLookupPage.url); await vehicleLookupPage.vehicleLookup(vehicleDetails!); }); await test.step('VinLookupPage >> Lookup by VIN', async () => { + await vinLookupPage.validateURL(vinLookupPage.url); await vinLookupPage.enterVin(vehicleDetails!.vin!); forceAPIError(page, '/parts/api/v1/parts') await vinLookupPage.nextPage(); }); await test.step('BailoutPage >> Parts Service Error Bailout', async () => { + await bailoutPage.validateURL(bailoutPage.url); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.PartsServiceError); return; }); @@ -485,11 +499,13 @@ async function runWorkflow(page: Page, testCase: TestCase) { await test.step('VehicleLookupPage >> Select Lookup Type' + vehicleDetails?.vehicleLookupType, async () => { + await vehicleLookupPage.validateURL(vehicleLookupPage.url); await vehicleLookupPage.vehicleLookup(vehicleDetails!); }); - if (testCase.testData.isVehicleSelectBailout) { + if (isVehicleSelectBailout) { + await vinLookupPage.validateURL(vinLookupPage.url); await test.step('Lookup vehicle >> By VIN-' + vehicleDetails!.vin!, async () => { await vinLookupPage.enterVin(vehicleDetails!.vin!); }); @@ -507,11 +523,13 @@ async function runWorkflow(page: Page, testCase: TestCase) { switch (vehicleDetails!.vehicleLookupType!) { case VehicleLookupType.Address: await test.step('VehicleLookupAddressPage >> Lookup by address: ' + customerDetails!.address.street, async () => { + await vehicleLookupAddressPage.validateURL(vehicleLookupAddressPage.url); await vehicleLookupAddressPage.lookupVehicleByAddress(customerDetails!, vehicleDetails!); await vehicleLookupAddressPage.nextPage(); }); break; case VehicleLookupType.LicensePlateNumber: + await vehicleLookupLicensePage.validateURL(vehicleLookupLicensePage.url); if (isVehicleLookupValidations) { await test.step('VehicleLookupLicensePage >> Lookup by license plate: ' + vehicleDetails!.licensePlateNumber, async () => { await vehicleLookupLicensePage.enterPlateDetails(vehicleDetails!, isVehicleLookupValidations); @@ -527,6 +545,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { break; case VehicleLookupType.Vin: await test.step('VinLookupPage >> Lookup by VIN: ' + vehicleDetails!.vin!, async () => { + await vinLookupPage.validateURL(vinLookupPage.url); await vinLookupPage.enterVin(vehicleDetails!.vin!, isVehicleLookupValidations); await vinLookupPage.nextPage(); }); @@ -535,6 +554,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } if (isMoldingQuestion) { await test.step('Molding Questions Page >> Select Yes', async () => { + await moldingQuestionsPage.validateURL(moldingQuestionsPage.url); if (!moldingQuestionsPage) { console.error("moldingQuestionsPage is not initialized"); } @@ -543,24 +563,28 @@ async function runWorkflow(page: Page, testCase: TestCase) { }); } if (capabilityQuestions && capabilityQuestions.length > 0) { + await capabilityQuestionsPage.validateURL(capabilityQuestionsPage.url); await capabilityQuestionsPage.validatePartQuestions(capabilityQuestions); await capabilityQuestionsPage.selectPartQuestionResponses(capabilityQuestions); await capabilityQuestionsPage.nextPage(); } if (partQuestions && partQuestions.length > 0) { + await partQuestionsPage.validateURL(partQuestionsPage.url); await partQuestionsPage.validatePartQuestions(partQuestions); await partQuestionsPage.selectPartQuestionResponses(partQuestions); await partQuestionsPage.nextPage(); } if (vehiclePartQuestions && vehiclePartQuestions.length > 0) { + await vehiclePartQuestionsPage.validateURL(vehiclePartQuestionsPage.url); await vehiclePartQuestionsPage.validatePartQuestions(vehiclePartQuestions); await vehiclePartQuestionsPage.selectPartQuestionResponses(vehiclePartQuestions); await vehiclePartQuestionsPage.nextPage(); } await test.step('CoverageStatementPage >> Next page', async () => { + await coverageStatementPage.validateURL(coverageStatementPage.url); // Confirm no coverage if (isPolicyFound && (isItac || isNoComp)) { await coverageStatementPage.continueToScheduleButton.click(); @@ -571,6 +595,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (hasStateLawPopup) { await test.step('ProviderPreferencePage >> Dismiss state law popup', async () => { + await providerPreferencePage.validateURL(providerPreferencePage.url); await providerPreferencePage.validateStateLawModalIsVisible(); await providerPreferencePage.gotItButton.click(); }); @@ -578,17 +603,20 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (!isPolicyFound || !(isItac || isNoComp)) { await test.step('ProviderPreferencePage >> Select Provider ' + isSafelite ? "Safelite" : "Other shops(Non-Safelite)", async () => { + await providerPreferencePage.validateURL(providerPreferencePage.url); await providerPreferencePage.selectProvider(isSafelite); }); } // validations for Recal warning mesage if (isRecalWarning) { + await serviceLocationPage.validateURL(serviceLocationPage.url); await serviceLocationPage.validateRecalWarning(); } // if isRecalNotifidation flag true additional step to acknowledge Recal notification. if (isRecalNotification) { + await providerPreferencePage.validateURL(providerPreferencePage.url); await providerPreferencePage.acknowledgeRecalNotificaiton(); } // If No-Comp or ITAC, ProviderPreferencePage does not appear @@ -599,6 +627,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (testCase.testData!.clientTag == '05CC1609-3631-4044-B45A-E78E13343B9A') { // Avoiding TPA flow for Federated Insureance due to Defect# SSR-1984 //Temporary fix until Defect# SSR-1984 is addressed. await test.step('***** Performing Safelite flow for Federal Insurance due to defec# SSR-1984 *****', async () => { }); await test.step('TpaSearchPage >> TPA Search', async () => { + await tpaSearchPage.validateURL(tpaSearchPage.url); await tpaSearchPage.selectFirstLocation(); // await tpaSearchPage.nextPage(); }); @@ -606,6 +635,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } if (isTpaNotEnabledBailout) { await test.step('validateBailoutDetails >> Bailout code : ' + BailoutCode.TPANotEnabled, async () => { + await bailoutPage.validateURL(bailoutPage.url); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.TPANotEnabled); return; }); @@ -614,23 +644,28 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isDoNotSeeMyShopBailout) { await test.step('TpaSearchPage >> Select "Do Not See My Shop"', async () => { + await tpaSearchPage.validateURL(tpaSearchPage.url); await tpaSearchPage.selectDoNotSeeMyShop(); }); + await bailoutPage.validateURL(bailoutPage.url); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.DoNotSeeMyShop); return; } await test.step('TpaSearchPage >> TPA Search', async () => { + await tpaSearchPage.validateURL(tpaSearchPage.url); await tpaSearchPage.selectFirstLocation(); await tpaSearchPage.nextPage(); }); await test.step('TpaSubmitPage >> TPA Submit', async () => { // TODO: Validations + await tpaSubmitPage.validateURL(tpaSubmitPage.url); await tpaSubmitPage.nextPage(); }); await test.step('TpaConfirmationPage >> TPA Confirmation', async () => { + await tpaConfirmationPage.validateURL(tpaConfirmationPage.url); await tpaConfirmationPage.validateSuccessMessage(); return; }); @@ -639,6 +674,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } await test.step('ServiceLocationPage >> Select service location', async () => { + await serviceLocationPage.validateURL(serviceLocationPage.url); await serviceLocationPage.selectLocation(appointmentDetails!); if (hasMilitaryWarning) { await expect.soft(serviceLocationPage.militaryWarningMessage).toBeVisible(); @@ -647,6 +683,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { }); await test.step('SchedulePage >> Select day and time', async () => { + await schedulePage.validateURL(schedulePage.url); customerDetails!.apptDate = await schedulePage.scheduleFirstAppointment(appointmentDetails!.serviceLocation); }); @@ -657,6 +694,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { email: customerDetails!.email, phoneNumber: customerDetails!.phoneNumber }; + await contactDetailsPage.validateURL(contactDetailsPage.url); const actualContactDetails = await contactDetailsPage.getContactDetails(); expect.soft(actualContactDetails).toEqual(expectedContactDetails); @@ -671,28 +709,33 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isPriceServiceErrorBailout) { await test.step('BailoutPage >> Price Service Error Bailout', async () => { + await bailoutPage.validateURL(bailoutPage.url); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.PricingResponseError); }); return; } await test.step('ServicePackagesPage >> Choose service package', async () => { + await servicePackagesPage.validateURL(servicePackagesPage.url); customerDetails!.packagePrice = await servicePackagesPage.selectServicePackage(servicePackage!); await servicePackagesPage.nextPage(); }); if (isPolicyFound && (isUseVehicleOnPolicy ?? true) && claimDetails!.policyDeductible > 0) { await test.step('PaymentMethodPage >> Execute Payment', async () => { + await paymentMethodPage.validateURL(paymentMethodPage.url); await paymentMethodPage.executePayment(paymentDetails!); await paymentMethodPage.nextPage(); }); } else { await test.step('PaymentMethodPage >> Skip to Order Confirmation', async () => { + await paymentMethodPage.validateURL(paymentMethodPage.url); await paymentMethodPage.nextPage(); }); } await test.step('OrderConfirmationPage >> Validate order', async () => { + await orderConfirmationPage.validateURL(orderConfirmationPage.url); await orderConfirmationPage.validateOrderConfirmationPage(testCase.testData); }); } From 16ce5ad0e4f9c871880a76d8a01c07471dca5d58 Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Fri, 7 Mar 2025 09:37:19 -0500 Subject: [PATCH 2/6] Update validateURL to account for more scenarios In some scenarios, the URL will not have already changed by the time this check is being made, so if the check fails, we wait and recheck a few times --- playwright-tests/pages/BasePage.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/playwright-tests/pages/BasePage.ts b/playwright-tests/pages/BasePage.ts index c241c45e..8b881b59 100644 --- a/playwright-tests/pages/BasePage.ts +++ b/playwright-tests/pages/BasePage.ts @@ -116,7 +116,21 @@ export class BasePage { } async validateURL(url: string) { - const currentUrl = this.page.url(); - expect(currentUrl).toEqual(url); + let failCount = 0; + /* + We can't assume that the URL has already changed when we get here, but the point of this + is to help speed up tests, so we want to move on as soon as we can if this passes, but + without waiting too long if it fails + */ + while(failCount < 10) { + await this.page.waitForTimeout(1000); + const currentUrl = this.page.url(); + if(currentUrl == url) + break; + else { + failCount++; + } + } + expect(failCount).not.toEqual(10); } } \ No newline at end of file From b935cf0efabc2d31814a38bb1ebb203ddc2fb98a Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Fri, 7 Mar 2025 11:01:59 -0500 Subject: [PATCH 3/6] Fixed some failing tests, some tweaks to url validation Extending URL validation timeout and adding some more logging/stepping to better see what is happening during tests --- .../business-logic/types/Enums.ts | 3 +- playwright-tests/pages/BasePage.ts | 34 +++++++++++-------- .../pages/VehicleLookupAddressPage.ts | 2 +- playwright-tests/tests/0000__M.test.ts | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/playwright-tests/business-logic/types/Enums.ts b/playwright-tests/business-logic/types/Enums.ts index 5221d0ea..2c86a60a 100644 --- a/playwright-tests/business-logic/types/Enums.ts +++ b/playwright-tests/business-logic/types/Enums.ts @@ -141,7 +141,8 @@ export enum BailoutCode { HeavyTruckVehicle, NoPartsAvailable, PartsServiceError, - SafeliteNotTheProvider + SafeliteNotTheProvider, + VehicleYMMSLookupError } export enum SignatureAlgorithm { diff --git a/playwright-tests/pages/BasePage.ts b/playwright-tests/pages/BasePage.ts index 8b881b59..0b3c8b0a 100644 --- a/playwright-tests/pages/BasePage.ts +++ b/playwright-tests/pages/BasePage.ts @@ -116,21 +116,25 @@ export class BasePage { } async validateURL(url: string) { - let failCount = 0; - /* - We can't assume that the URL has already changed when we get here, but the point of this - is to help speed up tests, so we want to move on as soon as we can if this passes, but - without waiting too long if it fails - */ - while(failCount < 10) { - await this.page.waitForTimeout(1000); - const currentUrl = this.page.url(); - if(currentUrl == url) - break; - else { - failCount++; + + await test.step(`Validating URL:${url}`, async () => { + let failCount = 0; + /* + We can't assume that the URL has already changed when we get here, but the point of this + is to help speed up tests, so we want to move on as soon as we can if this passes, but + without waiting too long if it fails + */ + while(failCount < 15) { + await this.page.waitForTimeout(1000); + const currentUrl = this.page.url(); + console.log(`Current URL: ${currentUrl}`) + if(currentUrl == url) + break; + else { + failCount++; + } } - } - expect(failCount).not.toEqual(10); + expect(failCount).not.toEqual(15); + }); } } \ No newline at end of file diff --git a/playwright-tests/pages/VehicleLookupAddressPage.ts b/playwright-tests/pages/VehicleLookupAddressPage.ts index ca2cd6f0..33b72cfd 100644 --- a/playwright-tests/pages/VehicleLookupAddressPage.ts +++ b/playwright-tests/pages/VehicleLookupAddressPage.ts @@ -8,7 +8,7 @@ export class VehicleLookupAddressPage extends BasePage { readonly page: Page; readonly addressForm: AddressForm; readonly vehicleSelectionForm: VehicleSelectionForm; - url = process.env['BASE_URL']! + '/?issPage=address-vehicles'; + url = process.env['BASE_URL']! + '/?issPage=address-lookup'; constructor(page: Page) { super(page); diff --git a/playwright-tests/tests/0000__M.test.ts b/playwright-tests/tests/0000__M.test.ts index 5802e1a8..095b9053 100644 --- a/playwright-tests/tests/0000__M.test.ts +++ b/playwright-tests/tests/0000__M.test.ts @@ -436,7 +436,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isVehicleLookupBailout) { await test.step('BailoutPage >> Vehicle Lookup Bailout', async () => { await bailoutPage.validateURL(bailoutPage.url); - await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.VehicleLookupError); + await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.VehicleYMMSLookupError); }); return; } From 49c951fe255c3586a17c58e79cbe5485e600cb0e Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Fri, 7 Mar 2025 11:47:06 -0500 Subject: [PATCH 4/6] Update validateURL to account for variations in query string In scenarios that reach the order confirmation page, the query string includes more than the issPageValue, whiche was breaking validateURL --- playwright-tests/pages/BailoutPage.ts | 2 +- playwright-tests/pages/BasePage.ts | 6 +- .../pages/CapabilityQuestionsPage.ts | 2 +- .../pages/ContactConfirmationPage.ts | 2 +- playwright-tests/pages/ContactDetailsPage.ts | 2 +- .../pages/CoverageStatementPage.ts | 2 +- playwright-tests/pages/DuplicateCheckPage.ts | 2 +- playwright-tests/pages/EndorsementsPage.ts | 2 +- .../pages/MoldingQuestionsPage.ts | 2 +- .../pages/OrderConfirmationPage.ts | 2 +- playwright-tests/pages/PartQuestionsPage.ts | 2 +- playwright-tests/pages/PaymentMethodPage.ts | 2 +- playwright-tests/pages/PaymentPage.ts | 2 +- .../pages/PolicyHolderDetailsPage.ts | 2 +- playwright-tests/pages/PolicyVehiclesPage.ts | 2 +- .../pages/ProviderPreferencePage.ts | 2 +- playwright-tests/pages/SchedulePage.ts | 2 +- playwright-tests/pages/ServiceLocationPage.ts | 2 +- playwright-tests/pages/ServicePackagesPage.ts | 2 +- playwright-tests/pages/TpaConfirmationPage.ts | 2 +- playwright-tests/pages/TpaSearchPage.ts | 2 +- playwright-tests/pages/TpaSubmitPage.ts | 2 +- playwright-tests/pages/VehicleDamagePage.ts | 2 +- .../pages/VehicleLookupAddressPage.ts | 2 +- .../pages/VehicleLookupLicensePage.ts | 2 +- playwright-tests/pages/VehicleLookupPage.ts | 2 +- playwright-tests/pages/VehiclePartsPage.ts | 2 +- .../pages/VehicleSelectionPage.ts | 2 +- playwright-tests/pages/VinLookupPage.ts | 2 +- playwright-tests/pages/WelcomePage.ts | 1 + playwright-tests/tests/0000__M.test.ts | 86 +++++++++---------- 31 files changed, 75 insertions(+), 74 deletions(-) diff --git a/playwright-tests/pages/BailoutPage.ts b/playwright-tests/pages/BailoutPage.ts index dbbfcf67..d387b15b 100644 --- a/playwright-tests/pages/BailoutPage.ts +++ b/playwright-tests/pages/BailoutPage.ts @@ -9,7 +9,7 @@ export class BailoutPage extends BasePage { readonly phoneNumberTextBox: Locator; readonly emailAddressTextBox: Locator; - url = process.env['BASE_URL']! + '/?issPage=bailout-page'; + issPageValue = 'bailout-page'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/BasePage.ts b/playwright-tests/pages/BasePage.ts index 0b3c8b0a..7ab18f94 100644 --- a/playwright-tests/pages/BasePage.ts +++ b/playwright-tests/pages/BasePage.ts @@ -115,9 +115,9 @@ export class BasePage { } - async validateURL(url: string) { + async validateURL(issPageValue: string) { - await test.step(`Validating URL:${url}`, async () => { + await test.step(`Validating page value:${issPageValue}`, async () => { let failCount = 0; /* We can't assume that the URL has already changed when we get here, but the point of this @@ -128,7 +128,7 @@ export class BasePage { await this.page.waitForTimeout(1000); const currentUrl = this.page.url(); console.log(`Current URL: ${currentUrl}`) - if(currentUrl == url) + if(currentUrl.includes(issPageValue)) break; else { failCount++; diff --git a/playwright-tests/pages/CapabilityQuestionsPage.ts b/playwright-tests/pages/CapabilityQuestionsPage.ts index 57ec7745..13fab9f2 100644 --- a/playwright-tests/pages/CapabilityQuestionsPage.ts +++ b/playwright-tests/pages/CapabilityQuestionsPage.ts @@ -2,7 +2,7 @@ import { Page } from "@playwright/test"; import { PartQuestionsPage } from "./PartQuestionsPage"; export default class CapabilityQuestionsPage extends PartQuestionsPage { - url = process.env['BASE_URL']! + '/?issPage=capability-questions'; + issPageValue = 'capability-questions'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/ContactConfirmationPage.ts b/playwright-tests/pages/ContactConfirmationPage.ts index c3b7bfc9..cd9b370f 100644 --- a/playwright-tests/pages/ContactConfirmationPage.ts +++ b/playwright-tests/pages/ContactConfirmationPage.ts @@ -6,7 +6,7 @@ export class ContactConfirmationPage extends BasePage { readonly page: Page; readonly ConfirmMessageLabel: Locator; - url = process.env['BASE_URL']! + '/?issPage=contact-confirmation'; + issPageValue = 'contact-confirmation'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/ContactDetailsPage.ts b/playwright-tests/pages/ContactDetailsPage.ts index 731ccf66..a942a12e 100644 --- a/playwright-tests/pages/ContactDetailsPage.ts +++ b/playwright-tests/pages/ContactDetailsPage.ts @@ -4,7 +4,7 @@ import { ICustomerDetails } from '@business-logic/types/CustomerDetails'; export class ContactDetailsPage extends BasePage { readonly page: Page; - url = process.env['BASE_URL']! + '/?issPage=contact-details'; + issPageValue = 'contact-details'; // Contact details form // TODO: Check if we can consolidate diff --git a/playwright-tests/pages/CoverageStatementPage.ts b/playwright-tests/pages/CoverageStatementPage.ts index 147bb19f..63246b42 100644 --- a/playwright-tests/pages/CoverageStatementPage.ts +++ b/playwright-tests/pages/CoverageStatementPage.ts @@ -8,7 +8,7 @@ export class CoverageStatementPage extends BasePage { readonly deductibleAmount: Locator; readonly verfiyingCoverageText: Locator; readonly continueToScheduleButton: Locator; // For ITAC/NoComp - url = process.env['BASE_URL']! + '/?issPage=coverage-statement'; + issPageValue = 'coverage-statement'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/DuplicateCheckPage.ts b/playwright-tests/pages/DuplicateCheckPage.ts index 10518b3f..c117db29 100644 --- a/playwright-tests/pages/DuplicateCheckPage.ts +++ b/playwright-tests/pages/DuplicateCheckPage.ts @@ -4,7 +4,7 @@ import { BasePage } from './BasePage'; export class DuplicateCheckPage extends BasePage { readonly page: Page; readonly newClaimButton: Locator; - url = process.env['BASE_URL']! + '/?issPage=duplicate-check'; + issPageValue = 'duplicate-check'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/EndorsementsPage.ts b/playwright-tests/pages/EndorsementsPage.ts index 1e86773f..8e154119 100644 --- a/playwright-tests/pages/EndorsementsPage.ts +++ b/playwright-tests/pages/EndorsementsPage.ts @@ -7,7 +7,7 @@ export class EndorsementsPage extends BasePage { readonly page: Page; readonly educatorYesButton: Locator; readonly educatorNoButton: Locator; - url = process.env['BASE_URL']! + '/?issPage=policy-endorsements'; + issPageValue = 'policy-endorsements'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/MoldingQuestionsPage.ts b/playwright-tests/pages/MoldingQuestionsPage.ts index ecb7fe7d..f8f6a555 100644 --- a/playwright-tests/pages/MoldingQuestionsPage.ts +++ b/playwright-tests/pages/MoldingQuestionsPage.ts @@ -3,7 +3,7 @@ import { BasePage } from './BasePage'; export class MoldingQuestionsPage extends BasePage { readonly page: Page; - url = process.env['BASE_URL']! + '/?issPage=part-questions'; + issPageValue = 'part-questions'; readonly yesButton: Locator; constructor(page: Page) { diff --git a/playwright-tests/pages/OrderConfirmationPage.ts b/playwright-tests/pages/OrderConfirmationPage.ts index 6f0ed1dc..2a4d6104 100644 --- a/playwright-tests/pages/OrderConfirmationPage.ts +++ b/playwright-tests/pages/OrderConfirmationPage.ts @@ -15,7 +15,7 @@ export class OrderConfirmationPage extends BasePage { readonly subtotalText: Locator; readonly finalAmountDue: Locator; readonly cartServicePackageText: Locator; - url = process.env['BASE_URL']! + '/?issPage=order-confirmation'; + issPageValue = 'order-confirmation'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/PartQuestionsPage.ts b/playwright-tests/pages/PartQuestionsPage.ts index 16f63ceb..1591b132 100644 --- a/playwright-tests/pages/PartQuestionsPage.ts +++ b/playwright-tests/pages/PartQuestionsPage.ts @@ -4,7 +4,7 @@ import { IPartQuestion } from '@business-logic/types/CustomerDetails'; export class PartQuestionsPage extends BasePage { readonly page: Page; - url = process.env['BASE_URL']! + '/?issPage=part-questions'; + issPageValue = 'part-questions'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/PaymentMethodPage.ts b/playwright-tests/pages/PaymentMethodPage.ts index bb4b3ecc..57d560be 100644 --- a/playwright-tests/pages/PaymentMethodPage.ts +++ b/playwright-tests/pages/PaymentMethodPage.ts @@ -15,7 +15,7 @@ export class PaymentMethodPage extends BasePage { readonly paypalButton: Locator; readonly paymentPage: PaymentPage; readonly paypalPage: PaypalPage; - url = process.env['BASE_URL']! + '/?issPage=payment-method'; + issPageValue = 'payment-method'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/PaymentPage.ts b/playwright-tests/pages/PaymentPage.ts index 1c2334c9..51942f0e 100644 --- a/playwright-tests/pages/PaymentPage.ts +++ b/playwright-tests/pages/PaymentPage.ts @@ -13,7 +13,7 @@ export class PaymentPage extends BasePage { readonly stateDropDown: Locator; readonly billingZipTextField: Locator; readonly submitPaymentButton: Locator; - url = process.env['BASE_URL']! + '/?issPage=payment-page'; + issPageValue = 'payment-page'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/PolicyHolderDetailsPage.ts b/playwright-tests/pages/PolicyHolderDetailsPage.ts index f9f8d9a7..47f11031 100644 --- a/playwright-tests/pages/PolicyHolderDetailsPage.ts +++ b/playwright-tests/pages/PolicyHolderDetailsPage.ts @@ -6,7 +6,7 @@ import { AddressForm } from './forms/AddressForm'; export class PolicyHolderDetailsPage extends BasePage { readonly page: Page; readonly addressForm: AddressForm; - readonly url = process.env['BASE_URL']! + '/?issPage=policy-holder-details'; + readonly issPageValue = 'policy-holder-details'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/PolicyVehiclesPage.ts b/playwright-tests/pages/PolicyVehiclesPage.ts index 0cd05b41..98b54217 100644 --- a/playwright-tests/pages/PolicyVehiclesPage.ts +++ b/playwright-tests/pages/PolicyVehiclesPage.ts @@ -4,7 +4,7 @@ import { IVehicleDetails } from '@business-logic/types/CustomerDetails'; export class PolicyVehiclesPage extends BasePage { readonly page: Page; - url = process.env['BASE_URL']! + '/?issPage=policy-vehicles'; + issPageValue = 'policy-vehicles'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/ProviderPreferencePage.ts b/playwright-tests/pages/ProviderPreferencePage.ts index 4bcfef51..7b6a53bc 100644 --- a/playwright-tests/pages/ProviderPreferencePage.ts +++ b/playwright-tests/pages/ProviderPreferencePage.ts @@ -9,7 +9,7 @@ export class ProviderPreferencePage extends BasePage { readonly gotItButton: Locator; readonly acknowledgeCheckbox: Locator; readonly stateLawModalHeading: Locator; - url = process.env['BASE_URL']! + '/?issPage=provider-preference'; + issPageValue = 'provider-preference'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/SchedulePage.ts b/playwright-tests/pages/SchedulePage.ts index 4003bcb9..0bd340dc 100644 --- a/playwright-tests/pages/SchedulePage.ts +++ b/playwright-tests/pages/SchedulePage.ts @@ -6,7 +6,7 @@ import { ServiceLocation } from '@business-logic/types/Enums'; export class SchedulePage extends BasePage { readonly page: Page; - url = process.env['BASE_URL']! + '/?issPage=schedule-page'; + issPageValue = 'schedule-page'; readonly firstAvailableDate: Locator; readonly firstAvailableTime: Locator; readonly modalContinueButton: Locator; diff --git a/playwright-tests/pages/ServiceLocationPage.ts b/playwright-tests/pages/ServiceLocationPage.ts index 4b855602..d84f87df 100644 --- a/playwright-tests/pages/ServiceLocationPage.ts +++ b/playwright-tests/pages/ServiceLocationPage.ts @@ -36,7 +36,7 @@ export class ServiceLocationPage extends BasePage { readonly vehicleProtectedNoButton: Locator; readonly saveAddressButton: Locator; - url = process.env['BASE_URL']! + '/?issPage=service-location'; + issPageValue = 'service-location'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/ServicePackagesPage.ts b/playwright-tests/pages/ServicePackagesPage.ts index e2b8ba67..9e8dd866 100644 --- a/playwright-tests/pages/ServicePackagesPage.ts +++ b/playwright-tests/pages/ServicePackagesPage.ts @@ -7,7 +7,7 @@ export class ServicePackagesPage extends BasePage { readonly standardPackageButton: Locator; readonly premiumPackageButton: Locator; readonly glassOnlyButton: Locator; - url = process.env['BASE_URL']! + '/?issPage=service-packages'; + issPageValue = 'service-packages'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/TpaConfirmationPage.ts b/playwright-tests/pages/TpaConfirmationPage.ts index 2dbb8b19..fb0460e2 100644 --- a/playwright-tests/pages/TpaConfirmationPage.ts +++ b/playwright-tests/pages/TpaConfirmationPage.ts @@ -4,7 +4,7 @@ import { BasePage } from './BasePage'; export class TpaConfirmationPage extends BasePage { readonly page: Page; readonly successMessage: Locator; - readonly url = process.env['BASE_URL']! + '/?issPage=tpa-confirmation'; + readonly issPageValue = 'tpa-confirmation'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/TpaSearchPage.ts b/playwright-tests/pages/TpaSearchPage.ts index 259f43f7..8f4b8639 100644 --- a/playwright-tests/pages/TpaSearchPage.ts +++ b/playwright-tests/pages/TpaSearchPage.ts @@ -5,7 +5,7 @@ export class TpaSearchPage extends BasePage { readonly page: Page; readonly firstLocationButton: Locator; readonly doNotSeeMyShopButton: Locator; - url = process.env['BASE_URL']! + '/?issPage=tpa-search'; + issPageValue = 'tpa-search'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/TpaSubmitPage.ts b/playwright-tests/pages/TpaSubmitPage.ts index bece6703..e563af7a 100644 --- a/playwright-tests/pages/TpaSubmitPage.ts +++ b/playwright-tests/pages/TpaSubmitPage.ts @@ -4,7 +4,7 @@ import { BasePage } from './BasePage'; export class TpaSubmitPage extends BasePage { readonly page: Page; readonly deductible: Locator; - url = process.env['BASE_URL']! + '/?issPage=tpa-submit'; + issPageValue = 'tpa-submit'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/VehicleDamagePage.ts b/playwright-tests/pages/VehicleDamagePage.ts index 58ec7515..a8fc147a 100644 --- a/playwright-tests/pages/VehicleDamagePage.ts +++ b/playwright-tests/pages/VehicleDamagePage.ts @@ -22,7 +22,7 @@ export class VehicleDamagePage extends BasePage { readonly rearWindowChkBox: Locator; readonly separateApptsWarning: Locator; readonly editVehicleButton: Locator; - url = process.env['BASE_URL']! + '/?issPage=vehicle-damage'; + issPageValue = 'vehicle-damage'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/VehicleLookupAddressPage.ts b/playwright-tests/pages/VehicleLookupAddressPage.ts index 33b72cfd..9f758323 100644 --- a/playwright-tests/pages/VehicleLookupAddressPage.ts +++ b/playwright-tests/pages/VehicleLookupAddressPage.ts @@ -8,7 +8,7 @@ export class VehicleLookupAddressPage extends BasePage { readonly page: Page; readonly addressForm: AddressForm; readonly vehicleSelectionForm: VehicleSelectionForm; - url = process.env['BASE_URL']! + '/?issPage=address-lookup'; + issPageValue = 'address-lookup'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/VehicleLookupLicensePage.ts b/playwright-tests/pages/VehicleLookupLicensePage.ts index 9dba3fd1..433ed849 100644 --- a/playwright-tests/pages/VehicleLookupLicensePage.ts +++ b/playwright-tests/pages/VehicleLookupLicensePage.ts @@ -8,7 +8,7 @@ export class VehicleLookupLicensePage extends BasePage { readonly licensePlateStateDrpDwn: Locator; readonly plateNoMatchError: Locator; readonly plateMismatchAlert: Locator; - url = process.env['BASE_URL']! + '/?issPage='; // TODO: Input correct URL + issPageValue = 'license-plate-lookup'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/VehicleLookupPage.ts b/playwright-tests/pages/VehicleLookupPage.ts index c2bd2046..1dab391e 100644 --- a/playwright-tests/pages/VehicleLookupPage.ts +++ b/playwright-tests/pages/VehicleLookupPage.ts @@ -14,7 +14,7 @@ export class VehicleLookupPage extends BasePage { readonly vinLookupPage: VinLookupPage; readonly vehicleLookupAddressPage: VehicleLookupAddressPage; readonly vehicleLookupLicensePage: VehicleLookupLicensePage; - url = process.env['BASE_URL']! + '/?issPage=vehicle-lookup'; + issPageValue = 'vehicle-lookup'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/VehiclePartsPage.ts b/playwright-tests/pages/VehiclePartsPage.ts index 908a2542..9671b7f9 100644 --- a/playwright-tests/pages/VehiclePartsPage.ts +++ b/playwright-tests/pages/VehiclePartsPage.ts @@ -2,7 +2,7 @@ import { Page } from "@playwright/test"; import { PartQuestionsPage } from "./PartQuestionsPage"; export default class VehiclePartQuestionsPage extends PartQuestionsPage{ - url = process.env['BASE_URL']! + '/?issPage=vehicle-parts'; + issPageValue = 'vehicle-parts'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/VehicleSelectionPage.ts b/playwright-tests/pages/VehicleSelectionPage.ts index dc9a19d2..383f2aa3 100644 --- a/playwright-tests/pages/VehicleSelectionPage.ts +++ b/playwright-tests/pages/VehicleSelectionPage.ts @@ -9,7 +9,7 @@ export class VehicleSelectionPage extends BasePage { readonly modelDropdown: Locator; readonly styleDropdown: Locator; - url = process.env['BASE_URL']! + '/?issPage=vehicle-selection'; + issPageValue = 'vehicle-selection'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/VinLookupPage.ts b/playwright-tests/pages/VinLookupPage.ts index 2ef93ee4..69c1f846 100644 --- a/playwright-tests/pages/VinLookupPage.ts +++ b/playwright-tests/pages/VinLookupPage.ts @@ -6,7 +6,7 @@ export class VinLookupPage extends BasePage { readonly vinLookupTextBox: Locator; readonly lookupVinForMe: Locator; readonly vinMismatchAlert: Locator; - url = process.env['BASE_URL']! + '/?issPage=vin-lookup'; // TODO: Input correct URL + issPageValue = 'vin-lookup'; constructor(page: Page) { super(page); diff --git a/playwright-tests/pages/WelcomePage.ts b/playwright-tests/pages/WelcomePage.ts index 8002ca56..62dceee6 100644 --- a/playwright-tests/pages/WelcomePage.ts +++ b/playwright-tests/pages/WelcomePage.ts @@ -17,6 +17,7 @@ export class WelcomePage extends BasePage { readonly state: Locator; readonly cookieCloseButton: Locator; url = process.env['BASE_URL']! + '/?issPage=welcome-page'; + issPageValue = 'welcome-page'; constructor(page: Page) { super(page); diff --git a/playwright-tests/tests/0000__M.test.ts b/playwright-tests/tests/0000__M.test.ts index 095b9053..5499792d 100644 --- a/playwright-tests/tests/0000__M.test.ts +++ b/playwright-tests/tests/0000__M.test.ts @@ -370,7 +370,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { // TODO: Dynamic for when we don't care if duplicate page appears await test.step('DuplicateCheckPage >> Start New Claim', async () => { - await duplicateCheckPage.validateURL(duplicateCheckPage.url); + await duplicateCheckPage.validateURL(duplicateCheckPage.issPageValue); await duplicateCheckPage.startNewClaim(); await duplicateCheckPage.nextPage(); }); @@ -378,7 +378,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isPolicyFound) { await test.step('PolicyVehiclesPage >> Select vehicle', async () => { - await policyVehiclesPage.validateURL(policyVehiclesPage.url); + await policyVehiclesPage.validateURL(policyVehiclesPage.issPageValue); await policyVehiclesPage.logReferralNumber(); // Validate other vehicles on policy if (otherVehiclesOnPolicy && otherVehiclesOnPolicy.length > 0) { @@ -400,7 +400,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isHeavyTruckVehicleBailout) { await test.step('BailoutPage >> Heavy Vehicle Bailout', async () => { - await bailoutPage.validateURL(bailoutPage.url); + await bailoutPage.validateURL(bailoutPage.issPageValue); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.HeavyTruckVehicle); }); return; @@ -408,7 +408,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (hasEndorsements) { await test.step('EndorsementsPage >> Select Endorsements', async () => { - await endorsementsPage.validateURL(endorsementsPage.url); + await endorsementsPage.validateURL(endorsementsPage.issPageValue); await endorsementsPage.verifyEndorsements(endorsements); await endorsementsPage.selectEndorsements(endorsements); await endorsementsPage.nextPage(); @@ -418,7 +418,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } else { await policyVehiclesPage.logReferralNumber(); await test.step('PolicyHolderDetailsPage >> Enter customer data', async () => { - await policyHolderDetailsPage.validateURL(policyHolderDetailsPage.url); + await policyHolderDetailsPage.validateURL(policyHolderDetailsPage.issPageValue); await policyHolderDetailsPage.fillCustomerDetails(customerDetails!); await policyHolderDetailsPage.nextPage(); }); @@ -428,14 +428,14 @@ async function runWorkflow(page: Page, testCase: TestCase) { } await test.step('VehicleDetailsPage >> Select Vehicle', async () => { - await vehicleSelectionPage.validateURL(vehicleSelectionPage.url); + await vehicleSelectionPage.validateURL(vehicleSelectionPage.issPageValue); await vehicleSelectionPage.selectVehicle(vehicleDetails!); await vehicleSelectionPage.nextPage(); }); if (isVehicleLookupBailout) { await test.step('BailoutPage >> Vehicle Lookup Bailout', async () => { - await bailoutPage.validateURL(bailoutPage.url); + await bailoutPage.validateURL(bailoutPage.issPageValue); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.VehicleYMMSLookupError); }); return; @@ -443,7 +443,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isHeavyTruckVehicleBailout) { await test.step('BailoutPage >> Heavy Vehicle Bailout', async () => { - await bailoutPage.validateURL(bailoutPage.url); + await bailoutPage.validateURL(bailoutPage.issPageValue); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.HeavyTruckVehicle); }); return; @@ -454,13 +454,13 @@ async function runWorkflow(page: Page, testCase: TestCase) { isPolicyFound = false; // Flow proceeds as unverified testCase.testData.isPolicyFound = false; await test.step('VehicleDamagePage >> Click Edit Vehicle', async () => { - await vehicleDamagePage.validateURL(vehicleDamagePage.url); + await vehicleDamagePage.validateURL(vehicleDamagePage.issPageValue); await vehicleDamagePage.editVehicleButton.click(); }); await test.step('VehicleDetailsPage >> Select edited vehicle', async () => { await test.step('VehicleDetailsPage >> Select Vehicle', async () => { - await vehicleSelectionPage.validateURL(vehicleSelectionPage.url); + await vehicleSelectionPage.validateURL(vehicleSelectionPage.issPageValue); await vehicleSelectionPage.selectVehicle(editVehicleDetails); await vehicleSelectionPage.nextPage(); }); @@ -468,7 +468,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } await test.step('VehicleDamagePage >> Select Damage', async () => { - await vehicleDamagePage.validateURL(vehicleDamagePage.url); + await vehicleDamagePage.validateURL(vehicleDamagePage.issPageValue); if (isSeparateApptsWarning) { await vehicleDamagePage.checkSeparateApptsWarning(); } @@ -478,17 +478,17 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isPartsServiceErrorBailout) { await test.step('VehicleLookupPage >> Select Lookup Type', async () => { - await vehicleLookupPage.validateURL(vehicleLookupPage.url); + await vehicleLookupPage.validateURL(vehicleLookupPage.issPageValue); await vehicleLookupPage.vehicleLookup(vehicleDetails!); }); await test.step('VinLookupPage >> Lookup by VIN', async () => { - await vinLookupPage.validateURL(vinLookupPage.url); + await vinLookupPage.validateURL(vinLookupPage.issPageValue); await vinLookupPage.enterVin(vehicleDetails!.vin!); forceAPIError(page, '/parts/api/v1/parts') await vinLookupPage.nextPage(); }); await test.step('BailoutPage >> Parts Service Error Bailout', async () => { - await bailoutPage.validateURL(bailoutPage.url); + await bailoutPage.validateURL(bailoutPage.issPageValue); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.PartsServiceError); return; }); @@ -499,13 +499,13 @@ async function runWorkflow(page: Page, testCase: TestCase) { await test.step('VehicleLookupPage >> Select Lookup Type' + vehicleDetails?.vehicleLookupType, async () => { - await vehicleLookupPage.validateURL(vehicleLookupPage.url); + await vehicleLookupPage.validateURL(vehicleLookupPage.issPageValue); await vehicleLookupPage.vehicleLookup(vehicleDetails!); }); if (isVehicleSelectBailout) { - await vinLookupPage.validateURL(vinLookupPage.url); + await vinLookupPage.validateURL(vinLookupPage.issPageValue); await test.step('Lookup vehicle >> By VIN-' + vehicleDetails!.vin!, async () => { await vinLookupPage.enterVin(vehicleDetails!.vin!); }); @@ -523,13 +523,13 @@ async function runWorkflow(page: Page, testCase: TestCase) { switch (vehicleDetails!.vehicleLookupType!) { case VehicleLookupType.Address: await test.step('VehicleLookupAddressPage >> Lookup by address: ' + customerDetails!.address.street, async () => { - await vehicleLookupAddressPage.validateURL(vehicleLookupAddressPage.url); + await vehicleLookupAddressPage.validateURL(vehicleLookupAddressPage.issPageValue); await vehicleLookupAddressPage.lookupVehicleByAddress(customerDetails!, vehicleDetails!); await vehicleLookupAddressPage.nextPage(); }); break; case VehicleLookupType.LicensePlateNumber: - await vehicleLookupLicensePage.validateURL(vehicleLookupLicensePage.url); + await vehicleLookupLicensePage.validateURL(vehicleLookupLicensePage.issPageValue); if (isVehicleLookupValidations) { await test.step('VehicleLookupLicensePage >> Lookup by license plate: ' + vehicleDetails!.licensePlateNumber, async () => { await vehicleLookupLicensePage.enterPlateDetails(vehicleDetails!, isVehicleLookupValidations); @@ -545,7 +545,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { break; case VehicleLookupType.Vin: await test.step('VinLookupPage >> Lookup by VIN: ' + vehicleDetails!.vin!, async () => { - await vinLookupPage.validateURL(vinLookupPage.url); + await vinLookupPage.validateURL(vinLookupPage.issPageValue); await vinLookupPage.enterVin(vehicleDetails!.vin!, isVehicleLookupValidations); await vinLookupPage.nextPage(); }); @@ -554,7 +554,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } if (isMoldingQuestion) { await test.step('Molding Questions Page >> Select Yes', async () => { - await moldingQuestionsPage.validateURL(moldingQuestionsPage.url); + await moldingQuestionsPage.validateURL(moldingQuestionsPage.issPageValue); if (!moldingQuestionsPage) { console.error("moldingQuestionsPage is not initialized"); } @@ -563,28 +563,28 @@ async function runWorkflow(page: Page, testCase: TestCase) { }); } if (capabilityQuestions && capabilityQuestions.length > 0) { - await capabilityQuestionsPage.validateURL(capabilityQuestionsPage.url); + await capabilityQuestionsPage.validateURL(capabilityQuestionsPage.issPageValue); await capabilityQuestionsPage.validatePartQuestions(capabilityQuestions); await capabilityQuestionsPage.selectPartQuestionResponses(capabilityQuestions); await capabilityQuestionsPage.nextPage(); } if (partQuestions && partQuestions.length > 0) { - await partQuestionsPage.validateURL(partQuestionsPage.url); + await partQuestionsPage.validateURL(partQuestionsPage.issPageValue); await partQuestionsPage.validatePartQuestions(partQuestions); await partQuestionsPage.selectPartQuestionResponses(partQuestions); await partQuestionsPage.nextPage(); } if (vehiclePartQuestions && vehiclePartQuestions.length > 0) { - await vehiclePartQuestionsPage.validateURL(vehiclePartQuestionsPage.url); + await vehiclePartQuestionsPage.validateURL(vehiclePartQuestionsPage.issPageValue); await vehiclePartQuestionsPage.validatePartQuestions(vehiclePartQuestions); await vehiclePartQuestionsPage.selectPartQuestionResponses(vehiclePartQuestions); await vehiclePartQuestionsPage.nextPage(); } await test.step('CoverageStatementPage >> Next page', async () => { - await coverageStatementPage.validateURL(coverageStatementPage.url); + await coverageStatementPage.validateURL(coverageStatementPage.issPageValue); // Confirm no coverage if (isPolicyFound && (isItac || isNoComp)) { await coverageStatementPage.continueToScheduleButton.click(); @@ -595,7 +595,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (hasStateLawPopup) { await test.step('ProviderPreferencePage >> Dismiss state law popup', async () => { - await providerPreferencePage.validateURL(providerPreferencePage.url); + await providerPreferencePage.validateURL(providerPreferencePage.issPageValue); await providerPreferencePage.validateStateLawModalIsVisible(); await providerPreferencePage.gotItButton.click(); }); @@ -603,20 +603,20 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (!isPolicyFound || !(isItac || isNoComp)) { await test.step('ProviderPreferencePage >> Select Provider ' + isSafelite ? "Safelite" : "Other shops(Non-Safelite)", async () => { - await providerPreferencePage.validateURL(providerPreferencePage.url); + await providerPreferencePage.validateURL(providerPreferencePage.issPageValue); await providerPreferencePage.selectProvider(isSafelite); }); } // validations for Recal warning mesage if (isRecalWarning) { - await serviceLocationPage.validateURL(serviceLocationPage.url); + await serviceLocationPage.validateURL(serviceLocationPage.issPageValue); await serviceLocationPage.validateRecalWarning(); } // if isRecalNotifidation flag true additional step to acknowledge Recal notification. if (isRecalNotification) { - await providerPreferencePage.validateURL(providerPreferencePage.url); + await providerPreferencePage.validateURL(providerPreferencePage.issPageValue); await providerPreferencePage.acknowledgeRecalNotificaiton(); } // If No-Comp or ITAC, ProviderPreferencePage does not appear @@ -627,7 +627,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (testCase.testData!.clientTag == '05CC1609-3631-4044-B45A-E78E13343B9A') { // Avoiding TPA flow for Federated Insureance due to Defect# SSR-1984 //Temporary fix until Defect# SSR-1984 is addressed. await test.step('***** Performing Safelite flow for Federal Insurance due to defec# SSR-1984 *****', async () => { }); await test.step('TpaSearchPage >> TPA Search', async () => { - await tpaSearchPage.validateURL(tpaSearchPage.url); + await tpaSearchPage.validateURL(tpaSearchPage.issPageValue); await tpaSearchPage.selectFirstLocation(); // await tpaSearchPage.nextPage(); }); @@ -635,7 +635,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } if (isTpaNotEnabledBailout) { await test.step('validateBailoutDetails >> Bailout code : ' + BailoutCode.TPANotEnabled, async () => { - await bailoutPage.validateURL(bailoutPage.url); + await bailoutPage.validateURL(bailoutPage.issPageValue); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.TPANotEnabled); return; }); @@ -644,28 +644,28 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isDoNotSeeMyShopBailout) { await test.step('TpaSearchPage >> Select "Do Not See My Shop"', async () => { - await tpaSearchPage.validateURL(tpaSearchPage.url); + await tpaSearchPage.validateURL(tpaSearchPage.issPageValue); await tpaSearchPage.selectDoNotSeeMyShop(); }); - await bailoutPage.validateURL(bailoutPage.url); + await bailoutPage.validateURL(bailoutPage.issPageValue); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.DoNotSeeMyShop); return; } await test.step('TpaSearchPage >> TPA Search', async () => { - await tpaSearchPage.validateURL(tpaSearchPage.url); + await tpaSearchPage.validateURL(tpaSearchPage.issPageValue); await tpaSearchPage.selectFirstLocation(); await tpaSearchPage.nextPage(); }); await test.step('TpaSubmitPage >> TPA Submit', async () => { // TODO: Validations - await tpaSubmitPage.validateURL(tpaSubmitPage.url); + await tpaSubmitPage.validateURL(tpaSubmitPage.issPageValue); await tpaSubmitPage.nextPage(); }); await test.step('TpaConfirmationPage >> TPA Confirmation', async () => { - await tpaConfirmationPage.validateURL(tpaConfirmationPage.url); + await tpaConfirmationPage.validateURL(tpaConfirmationPage.issPageValue); await tpaConfirmationPage.validateSuccessMessage(); return; }); @@ -674,7 +674,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { } await test.step('ServiceLocationPage >> Select service location', async () => { - await serviceLocationPage.validateURL(serviceLocationPage.url); + await serviceLocationPage.validateURL(serviceLocationPage.issPageValue); await serviceLocationPage.selectLocation(appointmentDetails!); if (hasMilitaryWarning) { await expect.soft(serviceLocationPage.militaryWarningMessage).toBeVisible(); @@ -683,7 +683,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { }); await test.step('SchedulePage >> Select day and time', async () => { - await schedulePage.validateURL(schedulePage.url); + await schedulePage.validateURL(schedulePage.issPageValue); customerDetails!.apptDate = await schedulePage.scheduleFirstAppointment(appointmentDetails!.serviceLocation); }); @@ -694,7 +694,7 @@ async function runWorkflow(page: Page, testCase: TestCase) { email: customerDetails!.email, phoneNumber: customerDetails!.phoneNumber }; - await contactDetailsPage.validateURL(contactDetailsPage.url); + await contactDetailsPage.validateURL(contactDetailsPage.issPageValue); const actualContactDetails = await contactDetailsPage.getContactDetails(); expect.soft(actualContactDetails).toEqual(expectedContactDetails); @@ -709,33 +709,33 @@ async function runWorkflow(page: Page, testCase: TestCase) { if (isPriceServiceErrorBailout) { await test.step('BailoutPage >> Price Service Error Bailout', async () => { - await bailoutPage.validateURL(bailoutPage.url); + await bailoutPage.validateURL(bailoutPage.issPageValue); await bailoutPage.validateBailoutDetails(customerDetails!, BailoutCode.PricingResponseError); }); return; } await test.step('ServicePackagesPage >> Choose service package', async () => { - await servicePackagesPage.validateURL(servicePackagesPage.url); + await servicePackagesPage.validateURL(servicePackagesPage.issPageValue); customerDetails!.packagePrice = await servicePackagesPage.selectServicePackage(servicePackage!); await servicePackagesPage.nextPage(); }); if (isPolicyFound && (isUseVehicleOnPolicy ?? true) && claimDetails!.policyDeductible > 0) { await test.step('PaymentMethodPage >> Execute Payment', async () => { - await paymentMethodPage.validateURL(paymentMethodPage.url); + await paymentMethodPage.validateURL(paymentMethodPage.issPageValue); await paymentMethodPage.executePayment(paymentDetails!); await paymentMethodPage.nextPage(); }); } else { await test.step('PaymentMethodPage >> Skip to Order Confirmation', async () => { - await paymentMethodPage.validateURL(paymentMethodPage.url); + await paymentMethodPage.validateURL(paymentMethodPage.issPageValue); await paymentMethodPage.nextPage(); }); } await test.step('OrderConfirmationPage >> Validate order', async () => { - await orderConfirmationPage.validateURL(orderConfirmationPage.url); + await orderConfirmationPage.validateURL(orderConfirmationPage.issPageValue); await orderConfirmationPage.validateOrderConfirmationPage(testCase.testData); }); } From e3428b0bf94cd4a709dd2e5ffa54a0587cce2cdb Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Fri, 7 Mar 2025 14:03:21 -0500 Subject: [PATCH 5/6] Update page value for molding questions, adjust timing of url validation --- playwright-tests/pages/BasePage.ts | 2 +- playwright-tests/pages/MoldingQuestionsPage.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/playwright-tests/pages/BasePage.ts b/playwright-tests/pages/BasePage.ts index 7ab18f94..2a910b45 100644 --- a/playwright-tests/pages/BasePage.ts +++ b/playwright-tests/pages/BasePage.ts @@ -125,7 +125,6 @@ export class BasePage { without waiting too long if it fails */ while(failCount < 15) { - await this.page.waitForTimeout(1000); const currentUrl = this.page.url(); console.log(`Current URL: ${currentUrl}`) if(currentUrl.includes(issPageValue)) @@ -133,6 +132,7 @@ export class BasePage { else { failCount++; } + await this.page.waitForTimeout(1000); } expect(failCount).not.toEqual(15); }); diff --git a/playwright-tests/pages/MoldingQuestionsPage.ts b/playwright-tests/pages/MoldingQuestionsPage.ts index f8f6a555..378a24c7 100644 --- a/playwright-tests/pages/MoldingQuestionsPage.ts +++ b/playwright-tests/pages/MoldingQuestionsPage.ts @@ -3,7 +3,7 @@ import { BasePage } from './BasePage'; export class MoldingQuestionsPage extends BasePage { readonly page: Page; - issPageValue = 'part-questions'; + issPageValue = 'molding-questions'; readonly yesButton: Locator; constructor(page: Page) { From a974e53bc80ad2467de81303edd405acd7b7be5e Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Mon, 10 Mar 2025 09:57:55 -0400 Subject: [PATCH 6/6] Use expect.toPass instead of timeout/while loop --- playwright-tests/pages/BasePage.ts | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/playwright-tests/pages/BasePage.ts b/playwright-tests/pages/BasePage.ts index 2a910b45..e538ee34 100644 --- a/playwright-tests/pages/BasePage.ts +++ b/playwright-tests/pages/BasePage.ts @@ -116,25 +116,12 @@ export class BasePage { } async validateURL(issPageValue: string) { - - await test.step(`Validating page value:${issPageValue}`, async () => { - let failCount = 0; - /* - We can't assume that the URL has already changed when we get here, but the point of this - is to help speed up tests, so we want to move on as soon as we can if this passes, but - without waiting too long if it fails - */ - while(failCount < 15) { - const currentUrl = this.page.url(); - console.log(`Current URL: ${currentUrl}`) - if(currentUrl.includes(issPageValue)) - break; - else { - failCount++; - } - await this.page.waitForTimeout(1000); - } - expect(failCount).not.toEqual(15); + await expect(async () => { + const currentUrl = this.page.url(); + expect(currentUrl).toContain(issPageValue); + }).toPass({ + intervals: [1_000], + timeout: 15_000 }); } } \ No newline at end of file