diff --git a/playwright-tests/pages/PaymentMethodPage.ts b/playwright-tests/pages/PaymentMethodPage.ts index 57d560be..ace2f8ac 100644 --- a/playwright-tests/pages/PaymentMethodPage.ts +++ b/playwright-tests/pages/PaymentMethodPage.ts @@ -8,25 +8,36 @@ import { PaypalPage } from './PaypalPage'; export class PaymentMethodPage extends BasePage { readonly page: Page; - readonly payAtServiceButton: Locator; - readonly havePaymentReadyMsg: Locator; - readonly payNowButton: Locator; - readonly payInFourButton: Locator; - readonly paypalButton: Locator; - readonly paymentPage: PaymentPage; readonly paypalPage: PaypalPage; + readonly paymentPage: PaymentPage; + + readonly payNowButton: Locator; + readonly paypalButton: Locator; + readonly payInFourButton: Locator; + readonly payAtAppointmentButton: Locator; + + readonly textReminderYesButton: Locator; + readonly textReminderNoButton: Locator; + readonly continueToCheckoutButton: Locator; + readonly submitButton: Locator; + issPageValue = 'payment-method'; constructor(page: Page) { super(page); this.page = page; - this.payAtServiceButton = this.page.locator('[buttonlabel="Pay at my appointment"]'); //this.page.getByText('Pay at time of service'); - this.havePaymentReadyMsg = this.page.getByText('Please have payment ready during your appointment.'); // it will be displayed when there is no payment option - this.payNowButton = this.page.locator('[buttonlabel="Pay now"]'); - this.payInFourButton = this.page.locator('[buttonlabel="Pay in 4 installments"]'); - this.paypalButton = this.page.frameLocator('iframe[name="card-frame"]').locator('div[id="paypalParentDiv"]'); - this.paymentPage = new PaymentPage(page); this.paypalPage = new PaypalPage(page); + this.paymentPage = new PaymentPage(page); + + this.payNowButton = this.page.locator('[buttonlabel="Pay now"]'); // credit and paypal options behind this button + this.paypalButton = this.page.frameLocator('iframe[name="card-frame"]').locator('div[id="paypalParentDiv"]'); + this.payInFourButton = this.page.locator('[buttonlabel="Pay in 4 installments"]'); // Afterpay + this.payAtAppointmentButton = this.page.locator('[buttonlabel="Pay at my appointment"]'); + + this.textReminderYesButton = this.page.locator('div.button-content', { hasText: /^yes$/i }); + this.textReminderNoButton = this.page.locator('div.button-content', { hasText: 'No' }); + this.continueToCheckoutButton = this.page.getByRole('button', { name: 'Continue to checkout' }); + this.submitButton = this.page.getByRole('button', { name: 'Submit' }); } async executePayment(paymentDetails: IPaymentDetails) { @@ -34,16 +45,22 @@ export class PaymentMethodPage extends BasePage { switch (paymentDetails.paymentType) { case PaymentType.Credit: - await this.selectCreditCard(); - await this.paymentPage.populateCreditCardDetails(paymentDetails); + await this.payNowButton.click(); + await this.textReminderYesButton.click(); + await this.continueToCheckoutButton.click(); + await this.selectCreditCard(paymentDetails); break; case PaymentType.Paypal: + await this.payNowButton.click(); + await this.textReminderYesButton.click(); + await this.continueToCheckoutButton.click(); await this.selectPaypal(); await this.paypalPage.completePaypalPurchase(paymentDetails); break; case PaymentType.AfterPay: await this.payInFourButton.click(); - await this.nextPage(); + await this.textReminderYesButton.click(); + await this.continueToCheckoutButton.click(); // Capture popup const afterpayPopup = await browserContext.waitForEvent('page'); @@ -54,7 +71,9 @@ export class PaymentMethodPage extends BasePage { break; case PaymentType.PayAtService: - await this.selectPayAtService(); + await this.payAtAppointmentButton.click(); + await this.textReminderYesButton.click(); + await this.submitButton.click(); break; default: console.error('PaymentMethodPage >> Logic for this payment method unimplemented'); @@ -63,22 +82,19 @@ export class PaymentMethodPage extends BasePage { } async selectPaypal() { - await this.payNowButton.click(); - await this.nextPage(); await this.paypalButton.click(); } - async selectCreditCard() { - await this.payNowButton.click(); - await this.nextPage(); + async selectCreditCard(paymentDetails: IPaymentDetails) { + await this.paymentPage.populateCreditCardDetails(paymentDetails); + } + + async selectPayAtAppointment() { + await this.payAtAppointmentButton.click(); } - async selectPayAtService() { - await this.payAtServiceButton.click(); + async submitOrderWithoutPIA() { + await this.textReminderYesButton.click(); + await this.submitButton.click(); } - - // async validateAmountDue(customer){ - // await this.amountDueDropDown.click(); - // await expect(this.deductibleAmountTextField).toContainText(`${customer.deductibleAmount}`); - // } } \ No newline at end of file diff --git a/playwright-tests/pages/PaymentPage.ts b/playwright-tests/pages/PaymentPage.ts index 51942f0e..fff2edd3 100644 --- a/playwright-tests/pages/PaymentPage.ts +++ b/playwright-tests/pages/PaymentPage.ts @@ -26,8 +26,7 @@ export class PaymentPage extends BasePage { this.cityTextField = page.frameLocator('iframe[name="card-frame"]').getByRole('textbox', { name: 'City' }); this.stateDropDown = page.frameLocator('iframe[name="card-frame"]').getByRole('combobox', { name: 'State' }); this.billingZipTextField = page.frameLocator('iframe[name="card-frame"]').getByRole('textbox', { name: 'Billing ZIP code' });; - this.submitPaymentButton = page.frameLocator('iframe[name="card-frame"]').locator('#buttonContainer'); - // this.validateURL(this.url); + this.submitPaymentButton = page.getByRole('button', { name: 'Submit payment' }); } async populateCreditCardDetails(paymentDetails: IPaymentDetails){