kaliiiiiiiiii / undetected-playwright-python

Undetected Python version of the Playwright testing and automation library.
https://playwright.dev/python/
Apache License 2.0
110 stars 13 forks source link

[BUG] iframe handle is not working #16

Open leoqian2019 opened 1 month ago

leoqian2019 commented 1 month ago

System info

Source code

import time

from undetected_playwright.sync_api import BrowserContext, sync_playwright

def iframe_test():
    with sync_playwright() as p:
        browser = p.chromium.launch(headless=False)
        page = browser.new_page()
        page.goto("https://www.dezlearn.com/nested-iframes-example/")
        # Click the first button
        parent_iframe = page.frame_locator("iframe#parent_iframe")
        parent_iframe.locator("#u_5_5").click(timeout=5000)
        # Click the second button in the nested iframe
        child_frame = parent_iframe.frame_locator("iframe#iframe1")
        child_frame.locator("#u_5_6").click()
        # Sleep to observe effects, generally not recommended for production code
        time.sleep(100)
        browser.close()
import time

from playwright.sync_api import BrowserContext, sync_playwright

def iframe_test():
    with sync_playwright() as p:
        browser = p.chromium.launch(headless=False)
        page = browser.new_page()
        page.goto("https://www.dezlearn.com/nested-iframes-example/")
        # Click the first button
        parent_iframe = page.frame_locator("iframe#parent_iframe")
        parent_iframe.locator("#u_5_5").click(timeout=5000)
        # Click the second button in the nested iframe
        child_frame = parent_iframe.frame_locator("iframe#iframe1")
        child_frame.locator("#u_5_6").click()
        # Sleep to observe effects, generally not recommended for production code
        time.sleep(100)
        browser.close()

Steps

Expected

Actual

andrey13771 commented 1 month ago

doubling up on this issue, looks like you can't do anything with the iframe, calling frame.content() get you an undetected_playwright._impl._errors.Error: Unable to retrieve content because the page is navigating and changing the content.

using undetected-playwright-patch==1.40.0.post1700587210000 vs latest playwright==1.44.0

andrey13771 commented 1 month ago

it does also happen with firefox