Removes URL declaration from page classes

Removes the explicit URL declaration from the page classes.

The URL validation and navigation are now handled directly within the tests, providing greater flexibility and control over test execution and removing the need to manage URLs within each page object.
This commit is contained in:
maguire-arman 2025-07-14 16:13:56 -04:00
parent 60c6a1cdc7
commit 458e552d6b
34 changed files with 2 additions and 70 deletions

View file

@ -8,7 +8,6 @@ export abstract class BaseHomePage extends BasePage {
constructor(page: Page) {
super(page);
this.page = page;
this.url = process.env['BASE_URL']!;
}
abstract letsGetStarted(zip?: string): Promise<void>;

View file

@ -53,11 +53,6 @@ export class BasePage {
}).toPass({ timeout: 240_000 });
}
async validateURL(url:string){
await expect(this.pageSpinner).toHaveCount(0, {timeout: 60000});
await this.page.waitForURL(url);
}
async fillAndValidate(element: Locator, value: string){
await expect(async () => {
var text = await element.textContent();

View file

@ -18,8 +18,6 @@ export class CCPolicyInfoPage extends InsuranceBasePage {
readonly isOtherPartyResponsibleForCoverage: Locator;
readonly lossLocation: Locator;
url = `${process.env['BASE_URL']!}/FixMyGlass/CCPolicyInfo.aspx*`;
constructor(page: Page) {
super(page);

View file

@ -5,7 +5,6 @@ import { ITestData } from 'framework/TestData';
import { ProgressBarPercentages } from 'framework/localTypes/Enums';
export default class CapabilityQuestionsPage extends PartQuestionsPage {
url = process.env['BASE_URL']! + '/fmg/?fmgPage=capability-questions';
constructor(page: Page) {
super(page);

View file

@ -7,7 +7,6 @@ import { ProgressBarPercentages } from 'framework/localTypes/Enums';
export class ContactDetailsPage extends BasePage {
readonly page: Page;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=customer-details';
// Contact details form
// TODO: Check if we can consolidate

View file

@ -12,7 +12,6 @@ export class CoverageStatementPage extends InsuranceBasePage {
readonly verifyingCoverageText: Locator;
readonly noCompText: Locator;
readonly continueButton: Locator; // For ITAC/NoComp
url = process.env['BASE_URL']! + '/FixMyGlass/CoverageStatement.aspx';
constructor(page: Page) {
super(page);
@ -23,7 +22,6 @@ export class CoverageStatementPage extends InsuranceBasePage {
this.verifyingCoverageText = this.page.getByRole('heading', { name: 'We\'re verifying your coverage' });
this.noCompText = this.page.getByRole('heading', { name: 'Your policy doesn\'t cover this service' });
this.continueButton = page.getByRole('button', { name: 'Continue' });
// this.validateURL(this.url);
}
async scheduleOnline(){

View file

@ -6,13 +6,11 @@ import { step } from 'framework/localTypes/Step';
export class DuplicateCheckPage extends InsuranceBasePage {
readonly page: Page;
readonly newClaimButton: Locator;
url = process.env['BASE_URL']! + '/FixMyGlass/DuplicateCheck.aspx';
constructor(page: Page) {
super(page);
this.page = page;
this.newClaimButton = page.locator('a').filter({ hasText: 'Start a new claim Start a new' });
// this.validateURL(this.url);
}
async startNewClaim(){

View file

@ -10,7 +10,6 @@ export class EndorsementsPage extends InsuranceBasePage {
readonly page: Page;
readonly educatorYesButton: Locator;
readonly educatorNoButton: Locator;
url = process.env['BASE_URL']! + '/FixMyGlass/PolicyEndorsements.aspx';
constructor(page: Page) {
super(page);

View file

@ -18,7 +18,6 @@ export class EstimatePage extends BasePage {
readonly zipLookupButton: Locator;
readonly vehicleLookupAddressPage: VehicleLookupAddressPage;
readonly vehicleLookupLicensePage: VehicleLookupLicensePage;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=estimate';
constructor(page: Page) {
super(page);
@ -28,8 +27,6 @@ export class EstimatePage extends BasePage {
this.addressLookupButton = page.getByLabel('Provide my home address', { exact: true });
this.licenseLookupButton = page.getByLabel('Provide my license plate #', { exact: true });
this.vinLookupPage = new VinLookupPage(page);
// this.validateURL(this.url);
}
async vehicleLookup(vehicleDetails: IVehicleDetails) {

View file

@ -53,7 +53,6 @@ export class HomePage extends BasePage {
async goto() {
await this.page.goto(process.env['BASE_URL']!);
// await this.validateURL(this.url);
}
async isCurrentVariant(): Promise<boolean> {

View file

@ -10,15 +10,11 @@ export class InsuranceCompanyPage extends BasePage {
readonly insuranceInputBox: Locator;
readonly payOnMyOwnLink: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=insurance-company';
constructor(page: Page) {
super(page);
this.page = page;
this.insuranceInputBox = this.page.getByRole('textbox', { name: 'Enter your insurance company' });
this.payOnMyOwnLink = this.page.getByRole('link', { name: 'Pay on my own' });
// this.validateURL(this.url);
}
async enterInsuranceCompany(company: string): Promise<void> {

View file

@ -9,7 +9,6 @@ export class LeadgenHomePage extends BasePage {
readonly page: Page;
readonly letsGetStartedButton: Locator;
readonly zipTextbox: Locator;
url = process.env['BASE_URL']!;
constructor(page: Page) {
super(page);
@ -21,7 +20,6 @@ export class LeadgenHomePage extends BasePage {
async goto() {
await this.page.goto(process.env['BASE_URL']!);
// await this.validateURL(this.url);
}
async letsGetStarted(zip: string) {

View file

@ -5,7 +5,6 @@ import { ITestData } from 'framework/TestData';
import { ProgressBarPercentages } from 'framework/localTypes/Enums';
export default class MoldingQuestionsPage extends PartQuestionsPage {
url = process.env['BASE_URL']! + '/fmg/?fmgPage=molding-questions';
constructor(page: Page) {
super(page);

View file

@ -23,8 +23,6 @@ export class OrderConfirmationPage extends BasePage {
readonly rainDefense: Locator;
readonly appointmentSummarySection: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=confirmation';
constructor(page: Page) {
super(page);
this.page = page;
@ -40,7 +38,6 @@ export class OrderConfirmationPage extends BasePage {
this.finalAmountDue = this.page.locator('div.amount-due');
this.cartServicePackageText = this.cartServicePackageText = this.page.locator('.cart-panel');
this.appointmentSummarySection = this.page.locator('.main .scheduleText, .main .add-to-calendar-text, .main .appointment-text, .main .duration-text-block');
// this.validateURL(this.url);
}
async validateOrderConfirmationPage(testData: Partial<ITestData>) {

View file

@ -7,7 +7,6 @@ import { ProgressBarPercentages } from 'framework/localTypes/Enums';
export class PartQuestionsPage extends BasePage {
readonly page: Page;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=part-questions';
constructor(page: Page) {
super(page);

View file

@ -43,8 +43,6 @@ export class PaymentMethodPage extends BasePage {
readonly rainDefenseText: Locator;
readonly deductibleText: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=payment-method';
constructor(page: Page) {
super(page);
this.page = page;

View file

@ -14,7 +14,6 @@ export class PaymentPage extends BasePage {
readonly billingZipTextField: Locator;
readonly submitPaymentButton: Locator;
readonly payPalButton: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=payment';
constructor(page: Page) {
super(page);
@ -29,7 +28,7 @@ export class PaymentPage extends BasePage {
this.billingZipTextField = page.frameLocator('iframe[name="card-frame"]').getByRole('textbox', { name: 'Billing ZIP code' });;
this.submitPaymentButton = page.frameLocator('iframe[name="card-frame"]').locator('#buttonContainer');
this.payPalButton = page.frameLocator('iframe[name="card-frame"]').locator('#paypalParentLink');
// this.validateURL(this.url);
}
async populateCreditCardDetails(paymentDetails: IPaymentDetails){

View file

@ -9,7 +9,6 @@ export class PolicyDriverPage extends InsuranceBasePage {
readonly driverListItems: Locator;
readonly driverNotListedOption: Locator;
readonly vehicleParkedOption: Locator;
url = process.env['BASE_URL']! + '/FixMyGlass/PolicyDriver.aspx';
constructor(page: Page) {
super(page);
@ -20,8 +19,6 @@ export class PolicyDriverPage extends InsuranceBasePage {
// Locators for driver options
this.driverNotListedOption = this.page.getByRole('link', { name: 'Driver not listed' });
this.vehicleParkedOption = this.page.getByRole('link', { name: 'Vehicle was parked' });
// this.validateURL(this.url);
}
async selectPolicyDriver(customerDetails: ICustomerDetails): Promise<void> {

View file

@ -6,14 +6,10 @@ export class PolicyInfoSubmittedPage extends InsuranceBasePage {
readonly page: Page;
readonly policyInfoMessage: Locator;
url = process.env['BASE_URL']! + '/FixMyGlass/PolicyInfoSubmitted.aspx';
constructor(page: Page) {
super(page);
this.page = page;
this.policyInfoMessage = this.page.getByRole('heading', { name: 'Your policy and vehicle' });
// this.validateURL(this.url);
}
async verifyPolicyInfoSubmitted(): Promise<void> {

View file

@ -6,12 +6,10 @@ import { step } from 'framework/localTypes/Step';
export class PolicyVehiclesPage extends InsuranceBasePage {
readonly page: Page;
url = process.env['BASE_URL']! + '/FixMyGlass/PolicyVehicle.aspx';
constructor(page: Page) {
super(page);
this.page = page;
// this.validateURL(this.url);
}
async validateVehicleIsOnPolicy(vehicleDetails: IVehicleDetails) {

View file

@ -3,7 +3,6 @@ import { InsuranceBasePage } from "./InsuranceBasePage";
import { step } from 'framework/localTypes/Step';
export default class RecalibrationInfoPage extends InsuranceBasePage {
url = process.env['BASE_URL']! + '/FixMyGlass/RecalibrationInfo.aspx';
readonly continueButton: Locator;

View file

@ -10,7 +10,6 @@ import { ITestData } from 'framework/TestData';
export class SchedulePage extends BasePage {
readonly page: Page;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=schedule';
readonly firstAvailableDate: Locator;
readonly firstAvailableTime: Locator;
readonly modalContinueButton: Locator;

View file

@ -39,8 +39,6 @@ export class ServiceLocationPage extends BasePage {
readonly vehicleProtectedNoButton: Locator;
readonly repeatedClicksModalCloseButton: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=service-location';
constructor(page: Page) {
super(page);
this.page = page;

View file

@ -20,15 +20,12 @@ export class ServicePackagesPage extends BasePage {
readonly emailInput: Locator;
readonly getMyQuoteButton: Locator;
readonly closeButton: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=quote';
//Enter a promo code modal
readonly promoCodeTextbox: Locator;
readonly applyPromoButton: Locator;
readonly repeatedClicksModalCloseButton: Locator;
constructor(page: Page) {
super(page);
this.page = page;
@ -45,8 +42,6 @@ export class ServicePackagesPage extends BasePage {
this.promoCodeTextbox = this.page.getByLabel('Enter a promo code');
this.applyPromoButton = this.page.getByRole('button', { name: 'Apply promo code' });
this.repeatedClicksModalCloseButton = this.page.locator('.QSISlider').locator('img[src*=\'close\']');
// this.validateURL(this.url);
}
async selectPaymentMethod(method: PaymentMethod): Promise<void> {

View file

@ -6,8 +6,6 @@ import { ProgressBarPercentages } from 'framework/localTypes/Enums';
export class ServiceZipPage extends LookupPage {
url = process.env['BASE_URL']! + '/fmg/?fmgPage=service-zip';
constructor(page: Page) {
super(page);
}

View file

@ -34,7 +34,6 @@ export class VehicleDamagePage extends BasePage {
readonly noReplacementAvailableAlert: Locator;
readonly bothReplaceRepairAlert: Locator;
readonly splitWindshieldAlert: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=vehicle-damage';
constructor(page: Page) {
super(page);

View file

@ -11,8 +11,6 @@ export class VehicleLookupAddressPage extends LookupPage {
readonly addressForm: AddressForm;
readonly vehicleSelectionForm: VehicleSelectionForm;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=service-zip';
constructor(page: Page) {
super(page);
this.addressForm = new AddressForm(page);

View file

@ -9,8 +9,6 @@ export class VehicleLookupLicensePage extends LookupPage {
readonly licensePlateNumTextBox: Locator;
readonly licensePlateStateDrpDwn: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=license-plate-lookup';
constructor(page: Page) {
super(page);
this.licensePlateNumTextBox = page.getByRole('textbox', { name: 'License plate number'});

View file

@ -5,7 +5,6 @@ import { ITestData } from 'framework/TestData';
import { ProgressBarPercentages } from 'framework/localTypes/Enums';
export default class VehiclePartQuestionsPage extends PartQuestionsPage{
url = process.env['BASE_URL']! + '/fmg/?fmgPage=vehicle-parts';
constructor(page: Page) {
super(page);

View file

@ -15,8 +15,6 @@ export class VehicleSelectionPage extends BasePage {
readonly zipCodeTextBox: Locator;
readonly discontinuedServiceAlert: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=vehicle';
constructor(page: Page) {
super(page);
this.page = page;
@ -26,7 +24,6 @@ export class VehicleSelectionPage extends BasePage {
this.styleDropdown = this.page.locator('#styleQuestionField');
this.zipCodeTextBox = this.page.getByRole('textbox', { name: 'Zip code' });
this.discontinuedServiceAlert = this.page.locator('.alert-danger.widget-name-AlertNoServiceWidget');
// this.validateURL(this.url);
}
async selectVehicle(vehicleDetails: IVehicleDetails) {

View file

@ -10,15 +10,12 @@ export class VerifyDetailsPage extends InsuranceBasePage {
readonly policyZipTextBox: Locator;
readonly damageDate: Locator;
url = process.env['BASE_URL']! + '/FixMyGlass/VerifyDetails.aspx';
constructor(page: Page) {
super(page);
this.page = page;
this.policyNumberTextBox = page.locator('#PolicyNumber');
this.policyZipTextBox = page.locator('#PolicyZip');
this.damageDate = page.locator('#LossDate');
// this.validateURL(this.url);
}
async verifyPolicyDetails(customerDetails: ICustomerDetails, claimDetails: IClaimDetails): Promise<void> {

View file

@ -10,8 +10,6 @@ export class VinLookupPage extends LookupPage {
readonly cameraButton: Locator;
readonly whereCanIFindMyVinLink: Locator;
url = process.env['BASE_URL']! + '/fmg/?fmgPage=vin-lookup';
constructor(page: Page) {
super(page);
this.vinLookupTextBox = page.getByRole('textbox', { name: 'Enter your VIN' });

View file

@ -2,7 +2,6 @@ import { type Page } from '@playwright/test';
import { LookupPage } from './LookupPage';
export class ZipLookupPage extends LookupPage {
url = process.env['BASE_URL']! + '/fmg/?fmgPage=service-zip';
constructor(page: Page) {
super(page);

View file

@ -200,7 +200,7 @@ async function runWorkflow(page: Page, testCase: TestCase) {
} else {
// If enterFunnelWithZip is true, add zip code to url
if (!!isEnterFunnelWithZip!) {
const currentUrl = page.url();
const currentUrl = process.env['BASE_URL']!;
const zipParam = `&zipCode=${customerDetails?.address.postalCode!}`;
if (!currentUrl.includes('zipCode=')) {
await page.goto(currentUrl + zipParam);