From 975e1c05ed33f7def6a154ef6863458d1144bdbe Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Wed, 29 Dec 2021 20:08:52 +0100 Subject: [PATCH] wait for Continue 'Device not supported' or iframe --- main.stealth.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.stealth.js b/main.stealth.js index c5b9efb..0c9e4f7 100644 --- a/main.stealth.js +++ b/main.stealth.js @@ -89,8 +89,11 @@ const newStealthContext = async (browser, contextOptions = {}) => { if (btnText.toLowerCase() == 'in library') { console.log('Already in library! Nothing to claim.'); } else { + console.log('Not in library yet! Click GET.') await page.click('[data-testid="purchase-cta-button"]'); // click Continue if 'Device not supported. This product is not compatible with your current device.' + // await page.waitForTimeout(1000); // wait for 1s since count does not wait. + await Promise.any([':has-text("Continue")', '#webPurchaseContainer iframe'].map(s => page.waitForSelector(s))); // wait for Continue xor iframe if (await page.locator(':has-text("Continue")').count() > 0) { console.log('Device not supported. This product is not compatible with your current device.'); await page.click('button:has-text("Continue")');