Update locators and flow for each payment option
This commit is contained in:
parent
5908b7b807
commit
c899e367d1
2 changed files with 45 additions and 30 deletions
|
|
@ -8,25 +8,36 @@ import { PaypalPage } from './PaypalPage';
|
||||||
|
|
||||||
export class PaymentMethodPage extends BasePage {
|
export class PaymentMethodPage extends BasePage {
|
||||||
readonly page: Page;
|
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 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';
|
issPageValue = 'payment-method';
|
||||||
|
|
||||||
constructor(page: Page) {
|
constructor(page: Page) {
|
||||||
super(page);
|
super(page);
|
||||||
this.page = 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.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) {
|
async executePayment(paymentDetails: IPaymentDetails) {
|
||||||
|
|
@ -34,16 +45,22 @@ export class PaymentMethodPage extends BasePage {
|
||||||
|
|
||||||
switch (paymentDetails.paymentType) {
|
switch (paymentDetails.paymentType) {
|
||||||
case PaymentType.Credit:
|
case PaymentType.Credit:
|
||||||
await this.selectCreditCard();
|
await this.payNowButton.click();
|
||||||
await this.paymentPage.populateCreditCardDetails(paymentDetails);
|
await this.textReminderYesButton.click();
|
||||||
|
await this.continueToCheckoutButton.click();
|
||||||
|
await this.selectCreditCard(paymentDetails);
|
||||||
break;
|
break;
|
||||||
case PaymentType.Paypal:
|
case PaymentType.Paypal:
|
||||||
|
await this.payNowButton.click();
|
||||||
|
await this.textReminderYesButton.click();
|
||||||
|
await this.continueToCheckoutButton.click();
|
||||||
await this.selectPaypal();
|
await this.selectPaypal();
|
||||||
await this.paypalPage.completePaypalPurchase(paymentDetails);
|
await this.paypalPage.completePaypalPurchase(paymentDetails);
|
||||||
break;
|
break;
|
||||||
case PaymentType.AfterPay:
|
case PaymentType.AfterPay:
|
||||||
await this.payInFourButton.click();
|
await this.payInFourButton.click();
|
||||||
await this.nextPage();
|
await this.textReminderYesButton.click();
|
||||||
|
await this.continueToCheckoutButton.click();
|
||||||
|
|
||||||
// Capture popup
|
// Capture popup
|
||||||
const afterpayPopup = await browserContext.waitForEvent('page');
|
const afterpayPopup = await browserContext.waitForEvent('page');
|
||||||
|
|
@ -54,7 +71,9 @@ export class PaymentMethodPage extends BasePage {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PaymentType.PayAtService:
|
case PaymentType.PayAtService:
|
||||||
await this.selectPayAtService();
|
await this.payAtAppointmentButton.click();
|
||||||
|
await this.textReminderYesButton.click();
|
||||||
|
await this.submitButton.click();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.error('PaymentMethodPage >> Logic for this payment method unimplemented');
|
console.error('PaymentMethodPage >> Logic for this payment method unimplemented');
|
||||||
|
|
@ -63,22 +82,19 @@ export class PaymentMethodPage extends BasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectPaypal() {
|
async selectPaypal() {
|
||||||
await this.payNowButton.click();
|
|
||||||
await this.nextPage();
|
|
||||||
await this.paypalButton.click();
|
await this.paypalButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectCreditCard() {
|
async selectCreditCard(paymentDetails: IPaymentDetails) {
|
||||||
await this.payNowButton.click();
|
await this.paymentPage.populateCreditCardDetails(paymentDetails);
|
||||||
await this.nextPage();
|
}
|
||||||
|
|
||||||
|
async selectPayAtAppointment() {
|
||||||
|
await this.payAtAppointmentButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectPayAtService() {
|
async submitOrderWithoutPIA() {
|
||||||
await this.payAtServiceButton.click();
|
await this.textReminderYesButton.click();
|
||||||
|
await this.submitButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
// async validateAmountDue(customer){
|
|
||||||
// await this.amountDueDropDown.click();
|
|
||||||
// await expect(this.deductibleAmountTextField).toContainText(`${customer.deductibleAmount}`);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
@ -26,8 +26,7 @@ export class PaymentPage extends BasePage {
|
||||||
this.cityTextField = page.frameLocator('iframe[name="card-frame"]').getByRole('textbox', { name: 'City' });
|
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.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.billingZipTextField = page.frameLocator('iframe[name="card-frame"]').getByRole('textbox', { name: 'Billing ZIP code' });;
|
||||||
this.submitPaymentButton = page.frameLocator('iframe[name="card-frame"]').locator('#buttonContainer');
|
this.submitPaymentButton = page.getByRole('button', { name: 'Submit payment' });
|
||||||
// this.validateURL(this.url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async populateCreditCardDetails(paymentDetails: IPaymentDetails){
|
async populateCreditCardDetails(paymentDetails: IPaymentDetails){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue