+
+
diff --git a/tests/playwright/fixtures/USD.spec.mjs b/tests/playwright/fixtures/USD.spec.mjs
index dba1ec5e6..41e3a262b 100644
--- a/tests/playwright/fixtures/USD.spec.mjs
+++ b/tests/playwright/fixtures/USD.spec.mjs
@@ -80,7 +80,7 @@ for (const environment of environments) {
test('PayPal Success @quick', async ({ page }) => {
redirectShopper = new RedirectShopper(page);
- await redirectShopper.doPayPalPayment();
+ await redirectShopper.doPayPalPayment(false, false, true);
await checkoutPage.expectSuccess();
});
});
@@ -251,4 +251,48 @@ for (const environment of environments) {
await accountPage.expectFailure();
});
});
+
+ test.describe.parallel(`${environment.name} USD`, () => {
+ test.beforeEach(async ({ page }) => {
+ await page.goto(`${environment.urlExtension}`);
+ });
+
+ test('PayPal Express @quick', async ({ page }) => {
+ checkoutPage = new environment.CheckoutPage(page);
+ await checkoutPage.addProductToCart();
+ await checkoutPage.navigateToCart(regionsEnum.US);
+ redirectShopper = new RedirectShopper(page);
+ await redirectShopper.doPayPalPayment(true, false, true);
+ if (environment.name.indexOf('v5') !== -1) {
+ await page.locator("button[value='place-order']").click();
+ await page.locator(".order-thank-you-msg").isVisible({ timeout: 20000 });
+ }
+ else {
+ await checkoutPage.expectSuccess();
+ }
+ });
+
+ test('PayPal Express shipping change @quick', async ({ page }) => {
+ checkoutPage = new environment.CheckoutPage(page);
+ await checkoutPage.addProductToCart();
+ await checkoutPage.navigateToCart(regionsEnum.US);
+ redirectShopper = new RedirectShopper(page);
+ await redirectShopper.doPayPalPayment(true, true, true);
+ if (environment.name.indexOf('v5') !== -1) {
+ await page.locator("button[value='place-order']").click();
+ await page.locator(".order-thank-you-msg").isVisible({ timeout: 20000 });
+ }
+ else {
+ await checkoutPage.expectSuccess();
+ }
+ });
+
+ test('PayPal Express Cancellation @quick', async ({ page }) => {
+ checkoutPage = new environment.CheckoutPage(page);
+ await checkoutPage.addProductToCart();
+ await checkoutPage.navigateToCart(regionsEnum.US);
+ redirectShopper = new RedirectShopper(page);
+ await redirectShopper.doPayPalPayment(true, false, false);
+ });
+ });
}
diff --git a/tests/playwright/pages/PaymentMethodsPage.mjs b/tests/playwright/pages/PaymentMethodsPage.mjs
index 26170b00f..cdf64f94b 100644
--- a/tests/playwright/pages/PaymentMethodsPage.mjs
+++ b/tests/playwright/pages/PaymentMethodsPage.mjs
@@ -32,16 +32,18 @@ export default class PaymentMethodsPage {
await iDealInput.click();
};
- initiatePayPalPayment = async () => {
+ initiatePayPalPayment = async (expressFlow, shippingChange, success) => {
// Paypal button locator on payment methods page
const payPalButton = this.page
.frameLocator('.adyen-checkout__paypal__button--paypal iframe.visible')
.locator('.paypal-button');
// Click PayPal radio button
- await this.page.click('#rb_paypal');
- await expect(this.page.locator('.adyen-checkout__paypal__button--paypal iframe.visible'),).toBeVisible({ timeout: 20000 });
-
+ if (!expressFlow) {
+ await this.page.click('#rb_paypal');
+ }
+ await expect(this.page.locator('.adyen-checkout__paypal__button--paypal iframe.visible'),).toBeVisible({ timeout: 20000 });
+
// Capture popup for interaction
const [popup] = await Promise.all([
this.page.waitForEvent('popup'),
@@ -60,13 +62,29 @@ export default class PaymentMethodsPage {
this.passwordInput = popup.locator('#password');
this.loginButton = popup.locator('#btnLogin');
this.agreeAndPayNowButton = popup.locator('#payment-submit-btn');
+ this.shippingMethodsDropdown = popup.locator('#shippingMethodsDropdown');
+ this.cancelButton = popup.locator('a[data-testid="cancel-link"]');
await this.emailInput.click();
await this.emailInput.fill(paymentData.PayPal.username);
await this.nextButton.click();
await this.passwordInput.fill(paymentData.PayPal.password);
await this.loginButton.click();
- await this.agreeAndPayNowButton.click();
+ await this.page.waitForTimeout(5000);
+
+ if (shippingChange){
+ await this.shippingMethodsDropdown.selectOption({ index: 2 }); // This selects the second option as first one is hidden by default in paypal modale
+ await this.page.waitForTimeout(5000);
+ }
+
+ if (success) {
+ await this.agreeAndPayNowButton.click();
+ }
+ else {
+ await this.cancelButton.click();
+ await this.page.goBack();
+ await expect(this.page.locator('.add-to-cart'),).toBeVisible({ timeout: 20000 });
+ }
};
initiateAmazonPayment = async (
@@ -173,7 +191,7 @@ export default class PaymentMethodsPage {
submitSimulator = async (testSuccess) => {
await this.page.locator('button[data-testid="payment-action-button"]').click();
- await this.page.locator('button[data-testid="ideal-box-bank-item-TESTNL2A"]').click();
+ await this.page.locator('div[id="bank-item-TESTNL2A"]').click();
const actionButton = testSuccess ? this.page.getByRole('button', { name: 'Success', exact: true }) : this.page.getByRole('button', { name: 'Cancellation', exact: true });
await actionButton.click();
};
diff --git a/tests/playwright/paymentFlows/redirectShopper.mjs b/tests/playwright/paymentFlows/redirectShopper.mjs
index 3561584fd..7b8c84caf 100644
--- a/tests/playwright/paymentFlows/redirectShopper.mjs
+++ b/tests/playwright/paymentFlows/redirectShopper.mjs
@@ -29,8 +29,8 @@ export class RedirectShopper {
await this.paymentMethodsPage.initiateOneyPayment(shopper);
};
- doPayPalPayment = async () => {
- await this.paymentMethodsPage.initiatePayPalPayment();
+ doPayPalPayment = async (expressFlow, shippingChange, success) => {
+ await this.paymentMethodsPage.initiatePayPalPayment(expressFlow, shippingChange, success);
};
doAmazonPayment = async (normalFlow, selectedCard, success) => {