42 lines
No EOL
1.5 KiB
TypeScript
42 lines
No EOL
1.5 KiB
TypeScript
import test, { expect, type Locator, type Page } from '@playwright/test';
|
|
import { BasePage } from './BasePage';
|
|
|
|
export class VinLookupPage extends BasePage {
|
|
readonly page: Page;
|
|
readonly vinLookupTextBox: Locator;
|
|
readonly lookupVinForMe: Locator;
|
|
readonly vinMismatchAlert: Locator;
|
|
url = process.env['BASE_URL']! + '/?issPage=vin-lookup'; // TODO: Input correct URL
|
|
|
|
constructor(page: Page) {
|
|
super(page);
|
|
this.page = page;
|
|
this.vinLookupTextBox = page.getByRole('textbox', { name: 'Enter your VIN' });
|
|
this.lookupVinForMe = page.getByRole('link', { name: 'look up your VIN' });
|
|
this.vinMismatchAlert = page.getByLabel('vehicle-not-matched-alert');
|
|
// this.validateURL(this.url);
|
|
}
|
|
|
|
async enterVin(vin: string | string[], isVehicleLookupValidations = false) {
|
|
if (Array.isArray(vin)) {
|
|
if (vin.length > 1) {
|
|
if (isVehicleLookupValidations) {
|
|
await this.vinLookupTextBox.fill(vin[0]);
|
|
await this.continueButton.click({ timeout: 1000 });
|
|
await expect(this.vinMismatchAlert).toBeVisible();
|
|
await this.vinLookupTextBox.fill(vin[1]);
|
|
}
|
|
} else {
|
|
console.warn("VIN array is blank. Either provide VIN as string or string[]")
|
|
}
|
|
|
|
} else {
|
|
await this.vinLookupTextBox.fill(vin);
|
|
}
|
|
}
|
|
|
|
async triggerBailout() {
|
|
await this.continueButton.click();
|
|
await this.lookupVinForMe.click();
|
|
}
|
|
} |