DigitalConsumer.ISS/playwright-tests/pages/VehicleLookupPage.ts
Alex Humphries 49c951fe25 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
2025-03-07 11:47:06 -05:00

61 lines
2.3 KiB
TypeScript

import { type Locator, type Page } from '@playwright/test';
import { BasePage } from './BasePage';
import { VehicleLookupType } from '@business-logic/types/Enums';
import { IVehicleDetails } from '@business-logic/types/CustomerDetails';
import { VinLookupPage } from './VinLookupPage';
import { VehicleLookupAddressPage } from './VehicleLookupAddressPage';
import { VehicleLookupLicensePage } from './VehicleLookupLicensePage';
export class VehicleLookupPage extends BasePage {
readonly page: Page;
readonly vinLookupButton: Locator;
readonly addressLookupButton: Locator;
readonly licenseLookupButton: Locator;
readonly vinLookupPage: VinLookupPage;
readonly vehicleLookupAddressPage: VehicleLookupAddressPage;
readonly vehicleLookupLicensePage: VehicleLookupLicensePage;
issPageValue = 'vehicle-lookup';
constructor(page: Page) {
super(page);
this.page = page;
this.vinLookupButton = page.getByLabel('Provide my VIN manually', { exact: true });
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) {
switch (vehicleDetails.vehicleLookupType) {
case VehicleLookupType.Address:
await this.selectAddressLookup();
await this.nextPage();
break;
case VehicleLookupType.LicensePlateNumber:
await this.selectLicenseLookup();
await this.nextPage();
break;
case VehicleLookupType.Vin:
await this.selectVinLookup();
await this.nextPage();
break;
default:
console.error('VehicleLookupPage >> DATA ISSUE: VehicleLookupType not provided');
break;
}
}
async selectVinLookup(){
await this.vinLookupButton.click();
}
async selectAddressLookup(){
await this.addressLookupButton.click();
}
async selectLicenseLookup(){
await this.licenseLookupButton.click();
}
}