diff --git a/playwright-tests/pages/VehiclePartsPage.ts b/playwright-tests/pages/VehiclePartsPage.ts index 9671b7f9..1d778f82 100644 --- a/playwright-tests/pages/VehiclePartsPage.ts +++ b/playwright-tests/pages/VehiclePartsPage.ts @@ -1,5 +1,6 @@ -import { Page } from "@playwright/test"; +import { expect, type Locator, type Page } from "@playwright/test"; import { PartQuestionsPage } from "./PartQuestionsPage"; +import { IPartQuestion } from '@business-logic/types/CustomerDetails'; export default class VehiclePartQuestionsPage extends PartQuestionsPage{ issPageValue = 'vehicle-parts'; @@ -7,4 +8,27 @@ export default class VehiclePartQuestionsPage extends PartQuestionsPage{ constructor(page: Page) { super(page); } +/* this fails for some reason/some cases so may need to rework maybe only validate for part questions page and not on vehicle parts +async validatePartQuestions(partQuestions: IPartQuestion[]) { + for (const pq of partQuestions) { + const partQuestionOptions = this.page.locator(`fieldset[aria-labelledby="${pq.partQuestionType}"]`); + if (pq.isOnPage) { + await expect(partQuestionOptions).toBeAttached(); + } else { + await expect(partQuestionOptions).not.toBeAttached(); + } + } + } +*/ + async selectPartQuestionResponses(partQuestions: IPartQuestion[]) { + for (const pq of partQuestions) { + const parentobject=this.page.locator(`fieldset[aria-labelledby="${pq.partQuestionType}"]`); + const partQuestionOptionButton = parentobject.locator(`[buttonlabel="${pq.optionToSelect}"]`); + await partQuestionOptionButton.nth(0).click(); + if (pq.secondaryQuestionOptionToSelect != null) { + const secondaryQuestionButton = parentobject.getByText(`${pq.secondaryQuestionOptionToSelect}`); + await secondaryQuestionButton.nth(1).click(); + } + } + } } \ No newline at end of file