From 0394dc3f944c9a68d230dac8a6c02c3effe6a46f Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Tue, 28 Dec 2021 20:16:00 +0100 Subject: [PATCH] exit on hcaptcha --- main.stealth.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.stealth.js b/main.stealth.js index d082124..b770892 100644 --- a/main.stealth.js +++ b/main.stealth.js @@ -90,6 +90,10 @@ const newStealthContext = async (browser, contextOptions = {}) => { const iframe = page.frameLocator('#webPurchaseContainer iframe') await iframe.locator('button:has-text("Place Order")').click(); await iframe.locator('button:has-text("I Agree")').click(); + if (await iframe.frameLocator('#talon_frame_checkout_free_prod').locator('text=Please complete a security check to continue').count() > 0) { + console.error('Encountered hcaptcha. Giving up :('); + process.exit(1); + } // await iframe.locator('button.payment-purchase-close').click(); console.log(await page.locator('[data-testid="purchase-cta-button"]').innerText()); await page.pause();