diff --git a/playwright-tests/pages/AfterpayPage.ts b/playwright-tests/pages/AfterpayPage.ts index b4c619c7..2f13ed04 100644 --- a/playwright-tests/pages/AfterpayPage.ts +++ b/playwright-tests/pages/AfterpayPage.ts @@ -34,15 +34,19 @@ export class AfterpayPage extends BasePage { } async executeAfterpayPayment(paymentDetails: IPaymentDetails, claimDetails: IClaimDetails, servicePackage: ServicePackage) { + + const confirmButtonOrPaymentOptions = this.confirmButton.or(this.selectAfterpayWithoutInterestButton); + await this.login(paymentDetails.password!); - try {await this.confirmButton.waitFor({ state: 'visible', timeout: 5000 }); - expect(this.confirmButton).toBeVisible(); - await this.confirmButton.click(); - } catch { - // For some orders, user will have 2 options to choose from: monthly with interest or biweekly without interest - await this.selectAfterpayWithoutInterestButton.waitFor({ state: 'visible' }); + await this.page.locator('div[data-testid=\'loading-icon-svg\']').filter({ visible: true}).first().waitFor({ state: 'hidden' }); + await confirmButtonOrPaymentOptions.waitFor({ state: 'visible' }); + if (await this.confirmButton.isVisible()) { + await this.confirmButton.waitFor({ state: 'attached' }); + await this.confirmButton.click(); + } else { + // For some orders, user will have 2 options to choose from: monthly with interest or biweekly without interest if (await this.selectAfterpayWithoutInterestButton.isVisible()) { await this.selectAfterpayWithoutInterestButton.click(); await this.continueAfterpayButton.click(); @@ -51,6 +55,6 @@ export class AfterpayPage extends BasePage { await this.continueAfterpayButton.click(); } await this.confirmButton.click(); - } } +} } \ No newline at end of file