Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Frame Locators are failing #9

Closed
1 task done
Vinyzu opened this issue Dec 22, 2023 · 13 comments
Closed
1 task done

[BUG] Frame Locators are failing #9

Vinyzu opened this issue Dec 22, 2023 · 13 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Vinyzu
Copy link

Vinyzu commented Dec 22, 2023

System info

  • Playwright Version: v1.40.0.post1700587210000
  • Operating System: All

Source code

  • I provided exact source code that allows reproducing the issue locally.

Test file (self-contained)

import asyncio
from playwright.async_api import Page as AsyncPage, async_playwright

async def bytedance():
    # playwright install chromium
    # playwright install-deps chromium
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=False)
        context = await browser.new_context(locale="en-US")
        page = await context.new_page()

        await page.goto("https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox-explicit.php")
        checkbox = page.frame_locator("iframe[title='reCAPTCHA']")
        await checkbox.locator(".recaptcha-checkbox-border").click()

if __name__ == "__main__":
    asyncio.run(bytedance())

Steps

  • Run the test
  • Timeout Error after 30.000ms (Locator for the Checkbox Border)

Expected
Passes on default playwright

Actual

D:\System\Lib\Python\Python310\python.exe D:\System\AppData\PyCharm\scratches\scratch.py 
Traceback (most recent call last):
  File "D:\System\AppData\PyCharm\scratches\scratch.py", line 17, in <module>
    asyncio.run(bytedance())
  File "D:\System\Lib\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\System\Lib\Python\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "D:\System\AppData\PyCharm\scratches\scratch.py", line 14, in bytedance
    await checkbox.locator(".recaptcha-checkbox-border").click()
  File "D:\Projects\PyCharm\undetected-playwright-python\undetected_playwright\async_api\_generated.py", line 15706, in click
    await self._impl_obj.click(
  File "D:\Projects\PyCharm\undetected-playwright-python\undetected_playwright\_impl\_locator.py", line 158, in click
    return await self._frame.click(self._selector, strict=True, **params)
  File "D:\Projects\PyCharm\undetected-playwright-python\undetected_playwright\_impl\_frame.py", line 494, in click
    await self._channel.send("click", locals_to_params(locals()))
  File "D:\Projects\PyCharm\undetected-playwright-python\undetected_playwright\_impl\_connection.py", line 63, in send
    return await self._connection.wrap_api_call(
  File "D:\Projects\PyCharm\undetected-playwright-python\undetected_playwright\_impl\_connection.py", line 495, in wrap_api_call
    return await cb()
  File "D:\Projects\PyCharm\undetected-playwright-python\undetected_playwright\_impl\_connection.py", line 101, in inner_send
    result = next(iter(done)).result()
undetected_playwright._impl._errors.TimeoutError: Timeout 30000ms exceeded.

Process finished with exit code 1
@Vinyzu
Copy link
Author

Vinyzu commented Dec 22, 2023

@exiutech
Copy link

exiutech commented Jan 9, 2024

yes . I encountered the same problem .

@ghost
Copy link

ghost commented Jan 19, 2024

Try adding this flags:
'--disable-web-security',
'--disable-site-isolation-trials',
'--disable-features=IsolateOrigins,site-per-process'

The downside of this is the cloudflare challenge will not passed anymore. I've tried using the patcher for playwright-node. It works for solving the cloudflare challenge but for some reason, accessing iframes is not working. The workaround that I've found is using the flags above. I think this is the one '--disable-site-isolation-trials' causing the cloudflare challenge to not pass but it is also the reason I can make the iframes operations working again. I'm just guessing though.

@raishid
Copy link

raishid commented Jan 28, 2024

I have the same problem

@kaliiiiiiiiii kaliiiiiiiiii added bug Something isn't working help wanted Extra attention is needed labels Jan 31, 2024
@luuzthebest
Copy link

i have the same problem

@Jaammerr
Copy link

same problem :(

@kaliiiiiiiiii
Copy link
Collaborator

I'm aware of this issue, currently just don't really have the time to fix it tho.
If you're relying on that, maybe using https://github.com/kaliiiiiiiiii/Selenium-Driverless is worth a consideration. It generally is more stealthy (developed from ground on to be as undetectable as possible) and receives more priority//maintainance as I don't have much hopes in this project//patch.
Playwright just isn't designed to be undetectable

@kaliiiiiiiiii
Copy link
Collaborator

kaliiiiiiiiii commented Mar 31, 2024

According to you, Undetectable playwright is a Patch, then it means it uses playwright module also, Then why can't You fix evaluation and script execution proxying to playwright? I guess script execution things have no match to detection?

@nandish486
Didn't say I couldn't fix it - just don't have the time to atm.
If this is urugent for you & driverless doesn't work for you, maybe consider

  1. supporting @Vinyzu and//or me (@kaliiiiiiiiii )
  2. develop//fix it yourself & submit a PR
  3. Hire someone to fix it

@kaliiiiiiiiii
Copy link
Collaborator

@nandish486

Yes brother I would like to help you, I started reading src, I found problem, and it is javascript context.

Mind giving us some some information?

  1. File(s, full path) & Line(s) reference? (if possible with url as reference)
  2. Why & where it exactly fails?
  3. What the necessary steps to fix it would be?

@kaliiiiiiiiii
Copy link
Collaborator

This issue has been resolved:

Upon inspecting the page source after it loads, it's apparent that the button you are attempting to click is nested within an iframe, which in turn is nested within another iframe.

iframe[name='recaptcha'] < iframe[title='reCAPTCHA'] < your button

To access the button, you'll need to use iframe.content_frame twice to navigate to the desired location.

As mentioned by @kaliiiiiiiiii in issue #12, JavaScript executions occur in isolated environments, necessitating navigation through different frames, as described above.

In short, direct access to frames within frames or to the top frame's iframe is not feasible; navigation is necessary.

This should address and resolve your problem effectively.

=> support for iframes required
Let's merge this issue into https://github.com/kaliiiiiiiiii/undetected-playwright-python/issues/5

@kaliiiiiiiiii kaliiiiiiiiii closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants
@Vinyzu @raishid @exiutech @Jaammerr @kaliiiiiiiiii @luuzthebest and others