Retry popup openning

sometimes checkout refreshes and the buttons becomes inactive for some time
This commit is contained in:
Alex P 2023-04-17 08:14:58 +03:00
parent e032edcc8c
commit 19f004becd
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -31,17 +31,24 @@ async function fillCheckoutForm(page) {
}
}
async function openPaypalPopup(page) {
await page.locator('.component-frame').scrollIntoViewIfNeeded();
async function openPaypalPopup(page, retry = true) {
try {
await page.locator('.component-frame').scrollIntoViewIfNeeded();
const [popup] = await Promise.all([
page.waitForEvent('popup'),
page.frameLocator('.component-frame').locator('[data-funding-source="paypal"]').click(),
]);
const [popup] = await Promise.all([
page.waitForEvent('popup', {timeout: 5000}),
page.frameLocator('.component-frame').locator('[data-funding-source="paypal"]').click(),
]);
await popup.waitForLoadState();
await popup.waitForLoadState();
return popup;
return popup;
} catch (err) {
if (retry) {
return openPaypalPopup(page, false);
}
throw err;
}
}
async function loginIntoPaypal(popup) {