DigitalConsumer.ISS/playwright-tests/pages/VehicleSelectionPage.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

42 lines
No EOL
1.7 KiB
TypeScript

import { expect, type Locator, type Page } from '@playwright/test';
import { BasePage } from './BasePage';
import { IVehicleDetails } from '@business-logic/types/CustomerDetails';
export class VehicleSelectionPage extends BasePage {
readonly page: Page;
readonly yearDropdown: Locator;
readonly makeDropdown: Locator;
readonly modelDropdown: Locator;
readonly styleDropdown: Locator;
issPageValue = 'vehicle-selection';
constructor(page: Page) {
super(page);
this.page = page;
this.yearDropdown = this.page.locator('#yearQuestionField');
this.makeDropdown = this.page.locator('#makeQuestionField');
this.modelDropdown = this.page.locator('#modelQuestionField');
this.styleDropdown = this.page.locator('#styleQuestionField');
// this.validateURL(this.url);
}
async selectVehicle(vehicleDetails: IVehicleDetails) {
await this.yearDropdown.selectOption(vehicleDetails.year);
await this.yearDropdown.press('Tab');
await this.makeDropdown.selectOption(vehicleDetails.make);
await expect(this.modelDropdown).toBeEditable({ timeout: 5000 });
await this.makeDropdown.press('Tab');
await this.modelDropdown.selectOption(vehicleDetails.model);
await expect(this.styleDropdown).toBeEditable({ timeout: 2000 });
await this.modelDropdown.press('Tab');
if (vehicleDetails.style) {
await this.styleDropdown.selectOption(vehicleDetails.style);
} else {
if (await this.styleDropdown.inputValue() === 'Select an option') {
await this.styleDropdown.selectOption({ index: 1 })
}
}
}
}