microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
67.38k stars 3.71k forks source link

[BUG] Frame not collected correctly #28966

Closed vvanglro closed 3 months ago

vvanglro commented 10 months ago

System info

Source code

from playwright.async_api import async_playwright

async def demo(url: str):
    async with async_playwright() as p:
        browser = await p.firefox.launch()
        context = await browser.new_context()
        page = await context.new_page()
        await page.goto(url, wait_until="networkidle")
        print(page.main_frame.child_frames)
        await browser.close()

if __name__ == "__main__":
    import asyncio
    import os
    os.environ["DEBUG"] = "pw:api"
    asyncio.run(demo("https://nowsecure.nl"))

Steps

  1. pip install --upgrade playwright==1.40.0

    child_frames is empty on the latest version of playwright 1.40.0. Output of running script:

    2024-01-12T08:03:08.803Z pw:api   navigated to "about:blank"
    2024-01-12T08:03:08.804Z pw:api   navigated to "about:blank"
    2024-01-12T08:03:08.807Z pw:api navigating to "https://nowsecure.nl/", waiting until "networkidle"
    2024-01-12T08:03:09.950Z pw:api   "commit" event fired
    2024-01-12T08:03:09.950Z pw:api   navigated to "https://nowsecure.nl/"
    2024-01-12T08:03:10.190Z pw:api   navigated to "https://nowsecure.nl/?__cf_chl_rt_tk=DgcQhDU.ellANM2t2jYa86RYb_LI5CD3puzpdiBXMUA-1705046589-0-gaNycGzNDOU"
    2024-01-12T08:03:10.193Z pw:api   "domcontentloaded" event fired
    2024-01-12T08:03:10.730Z pw:api   navigated to "https://nowsecure.nl/"
    2024-01-12T08:03:10.730Z pw:api   "load" event fired
    2024-01-12T08:03:18.961Z pw:api   "commit" event fired
    2024-01-12T08:03:18.961Z pw:api   navigated to "https://nowsecure.nl/"
    2024-01-12T08:03:18.961Z pw:api   navigated to "https://nowsecure.nl/?__cf_chl_rt_tk=g8l3reaam5_XsZWlxV4ffQ_0oSpB7iAZlCeVLDT0lcY-1705046598-0-gaNycGzNCSU"
    2024-01-12T08:03:18.961Z pw:api   "domcontentloaded" event fired
    2024-01-12T08:03:19.771Z pw:api   navigated to "https://nowsecure.nl/"
    2024-01-12T08:03:19.771Z pw:api   "load" event fired
    2024-01-12T08:03:24.968Z pw:api   "networkidle" event fired
    [<Frame name= url=''>]
pip install --upgrade playwright==1.25.0

In version of playwright 1.25.0, child_frames is correct. Output of running script:

2024-01-12T07:54:09.202Z pw:api   navigated to "about:blank"
2024-01-12T07:54:09.219Z pw:api   navigated to "about:blank"
2024-01-12T07:54:09.223Z pw:api navigating to "https://nowsecure.nl/", waiting until "networkidle"
2024-01-12T07:54:10.179Z pw:api   "commit" event fired
2024-01-12T07:54:10.180Z pw:api   navigated to "https://nowsecure.nl/"
2024-01-12T07:54:10.460Z pw:api   navigated to "https://nowsecure.nl/?__cf_chl_rt_tk=LbevaL2D.f7ykeFXiQoGJBFxoezHk5hTzReGIRmBg_g-1705046050-0-gaNycGzNDRA"
2024-01-12T07:54:10.466Z pw:api   "domcontentloaded" event fired
2024-01-12T07:54:12.747Z pw:api   navigated to "https://nowsecure.nl/"
2024-01-12T07:54:12.751Z pw:api   "load" event fired
2024-01-12T07:54:14.140Z pw:api   navigated to "https://challenges.cloudflare.com/cdn-cgi/challenge-platform/h/b/turnstile/if/ov2/av0/rcv0/0/x0r7a/0x4AAAAAAADnPIDROrmt1Wwj/light/normal"
2024-01-12T07:54:16.723Z pw:api   navigated to "https://challenges.cloudflare.com/cdn-cgi/challenge-platform/h/b/turnstile/if/ov2/av0/rcv0/0/x0r7a/0x4AAAAAAADnPIDROrmt1Wwj/light/normal"
[<Frame name=cf-chl-widget-x0r7a url='https://challenges.cloudflare.com/cdn-cgi/challenge-platform/h/b/turnstile/if/ov2/av0/rcv0/0/x0r7a/0x4AAAAAAADnPIDROrmt1Wwj/light/normal'>]
2024-01-12T07:54:18.981Z pw:api   "networkidle" event fired

Expected The output of the Playwright version 1.25.0 run script is the expected behavior.

[<Frame name=cf-chl-widget-x0r7a url='https://challenges.cloudflare.com/cdn-cgi/challenge-platform/h/b/turnstile/if/ov2/av0/rcv0/0/x0r7a/0x4AAAAAAADnPIDROrmt1Wwj/light/normal'>]

Actual The output of the Playwright version 1.40.0 run script is the actual behavior.

[<Frame name= url=''>]
KRRT7 commented 10 months ago

I am also having issues with Frames not being resolved correctly. would like a solution to it.

pavelfeldman commented 3 months ago

Why was this issue closed?

Thank you for your contribution to our project. This issue has been closed due to its limited upvotes and recent activity, and insufficient feedback for us to effectively act upon. Our priority is to focus on bugs that reflect higher user engagement and have actionable feedback, to ensure our bug database stays manageable.

Should you feel this closure was in error, please create a new issue and reference this one. We're open to revisiting it given increased support or additional clarity. Your understanding and cooperation are greatly appreciated.