Refactor playwright test

This commit is contained in:
Alex P 2023-03-22 11:37:32 +02:00
parent b388d2320c
commit f2ee714880
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -30,22 +30,34 @@ async function fillCheckoutForm(page) {
}
}
test('PayPal button place order from Product page', async ({page}) => {
await page.goto(PRODUCT_URL);
async function openPaypalPopup(page) {
await page.locator('.component-frame').scrollIntoViewIfNeeded();
const [popup] = await Promise.all([
page.waitForEvent('popup'),
page.frameLocator('.component-frame').locator('[data-funding-source="paypal"]').click(),
]);
await popup.waitForLoadState();
return popup;
}
async function loginIntoPaypal(popup) {
await popup.click("text=Log in");
await popup.fill('[name="login_email"]', CUSTOMER_EMAIL);
await popup.locator('#btnNext').click();
await popup.fill('[name="login_password"]', CUSTOMER_PASSWORD);
await popup.locator('#btnLogin').click();
}
test('PayPal button place order from Product page', async ({page}) => {
await page.goto(PRODUCT_URL);
const popup = await openPaypalPopup(page);
await loginIntoPaypal(popup);
await popup.locator('#payment-submit-btn').click();