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
361 stars 27 forks source link

Unable to interact with Frames in Python Playwright #51

Open OnaZeroN opened 1 month ago

OnaZeroN commented 1 month ago

After receiving a frame, rebrowser_playwright cannot interact with objects on it:

Code example:

While True:
    frame = page.frame(url=“some.url”)
    if frame:
        break
    await asyncio.sleep(1)
await frame.content()

Output: rebrowser_playwright._impl._errors.Error: Frame.content: Unable to retrieve content because the page is navigating and changing the content.

There is no such problem on regular Playwright.

Please let me know if you need more information to help with this problem!

BDawgBigMoney commented 1 month ago

Having the same issue.

nwebson commented 1 month ago

I just released a new version of the patch. I've refactored Playwright patch, so it's using addBinding method that I've used for Puppeteer patch a few weeks ago. Seems like this method works quite good, no bugs reported so far. Iframes work fine, proper access to main and isolated worlds. The only broken piece is page.pause() feature, but it shouldn't be a dealbreaker in prod env, and you can easily disable the fix during debugging. You can use it by patching library in your sources or you can install already patched playwright-core from npm.

BDawgBigMoney commented 1 month ago

Works for me. Get this error though '[rebrowser-patches][frames._context] cannot get world, error: TypeError: Cannot set properties of undefined (setting 'main')' but it works.

nwebson commented 1 month ago

@BDawgBigMoney could you please share URL and code where it happens, so I could debug it?

BDawgBigMoney commented 1 month ago

@BDawgBigMoney could you please share URL and code where it happens, so I could debug it?

I can't share the full code, as it requires authentication on a website, I can try to recreate the error on a other website but this is what the error looks like

[rebrowser-patches][frames._context] cannot get world, error: TypeError: Cannot set properties of undefined (setting 'main')
    at /home/user/Desktop/project/node_modules/playwright-core/lib/server/frames.js:715:38
    at runNextTicks (node:internal/process/task_queues:60:5)
    at processImmediate (node:internal/timers:447:9)
    at process.topLevelDomainCallback (node:domain:161:15)
    at process.callbackTrampoline (node:internal/async_hooks:126:24)
    at async Frame.evaluateExpression (/home/user/Desktop/project/node_modules/playwright-core/lib/server/frames.js:769:21)

It still manages to interact with the iframe though. Do you know this error still avoids CDP detection or does it just stop attempting to avoid it?

nwebson commented 1 month ago

Could you use REBROWSER_PATCHES_DEBUG=1 so we can see more detailed log? It doesn't break cdp leak fix, it's still undetectable. It's probably something about missing frame, but would be nice to see fuller logs.

chrisemke commented 3 weeks ago

I'm having this issue too with playwright python using firefox browser rebrowser-playwright>=1.48.100

nwebson commented 3 weeks ago

@chrisemke these patches are designed for Chrome only, Firefox wasn't tested. Please open a separate ticket if you need Firefox support.