[BUG] iframe handle is not working
Closed this issue · 4 comments
leoqian2019 commented
System info
- Playwright Version: [v1.43.0]
- Operating System: [macOS 14.5]
- Browser: [Chromium]
- Other 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
- run the method - iframe_test using the undetected_playwright package
- then try to run the same method using the original playwright package
Expected
- After the website is loaded, it should be able to click the two buttons specified
Actual
- However, nothing happens if I'm using the undetected_playwright package, the code didn't even recognize the iframe; on the other hand, the method with original playwright runs with no problem
andrey13771 commented
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
it does also happen with firefox
starkiller43 commented
seem problem.undetected-playwright-patch==1.40.0.post1700587210000
Vinyzu commented
Solved with Update to Patchright.