rebrowser / rebrowser-patches

Collection of patches for puppeteer and playwright to avoid automation detection and leaks. Helps to avoid Cloudflare and DataDome CAPTCHA pages. Easy to patch/unpatch, can be enabled/disabled on demand.
https://rebrowser.net
376 stars 28 forks source link

iframe.click is not working #37

Closed Shijomon closed 1 month ago

Shijomon commented 1 month ago

I get issue with iframe.click once i added the patches to puppeteer-core

Switched to iframe successfully audio button found Error getting audio file: ProtocolError: Input.dispatchMouseEvent timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed. at (file:///C:/Users/shijo/Desktop/Myworkspae/Datadome/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:89:14) at new Callback (file:///C:/Users/shijo/Desktop/Myworkspae/Datadome/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:93:16) at CallbackRegistry.create (file:///C:/Users/shijo/Desktop/Myworkspae/Datadome/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:19:26) at Connection._rawSend (file:///C:/Users/shijo/Desktop/Myworkspae/Datadome/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Connection.js:86:26) at CdpCDPSession.send (file:///C:/Users/shijo/Desktop/Myworkspae/Datadome/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/CDPSession.js:63:33) at file:///C:/Users/shijo/Desktop/Myworkspae/Datadome/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Input.js:297:33 at #withTransaction (file:///C:/Users/shijo/Desktop/Myworkspae/Datadome/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Input.js:234:19) at CdpMouse.down (file:///C:/Users/shijo/Desktop/Myworkspae/Datadome/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Input.js:292:36) at CdpMouse.click (file:///C:/Users/shijo/Desktop/Myworkspae/Datadome/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Input.js:342:27) at CdpElementHandle.click (file:///C:/Users/shijo/Desktop/Myworkspae/Datadome/node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.js:716:43)

async function switchToChallengeFrame(page) { const frames = page.frames(); let iframeFound = false; for (const frame of frames) { const frameElement = await frame.frameElement(); if (frameElement) { const tagName = await frameElement.getProperty('tagName').then(tag => tag.jsonValue()); if (tagName === 'IFRAME') { iframeFound = true; try { await frame.waitForSelector('#captcha-container', { timeout: 10000 }); console.log('Switched to iframe successfully'); return frame; } catch (error) { console.error('Could not access elements inside iframe:', error); return null; } } } }

if (!iframeFound) {
    console.error('No iframe found');
}
return null;

}

await iframe.waitForSelector('#captchaaudiobutton', { timeout: 5000 }); console.log("audio button found"); await iframe.click('#captchaaudiobutton'); console.log("clicked");

const iframePageSource = await iframe.evaluate(() => document.documentElement.outerHTML); const captchaAudioChallengePathRegex = /captchaAudioChallengePath: '(.*?)'/;

nwebson commented 1 month ago

📣 I just released a new version of rebrowser-patches with a completely new fix for Runtime.Enable leak. This fix doesn't lose access to main context and also works in workers 🎉 It's a complete drop-in replacement, so you don't need to change any of your existing code. Please try your code with new version.

nwebson commented 1 month ago

Thanks for reporting this bug. I just fixed it and now addBinding method (default one) fully supports iframes. Please check the new version and report back.