Add logic to select part question responses
This commit is contained in:
parent
caf186d728
commit
54c45fddb5
1 changed files with 25 additions and 1 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue