[BUG] (Action) Selectors do not Work after Manual Content Setting
Vinyzu opened this issue · comments
Source code
- I provided exact source code that allows reproducing the issue locally.
Test file (self-contained)
import asyncio
# undetected-playwright here!
from playwright.async_api import async_playwright, Playwright
async def run(playwright: Playwright):
args = []
# disable navigator.webdriver:true flag
args.append("--disable-blink-features=AutomationControlled")
browser = await playwright.chromium.launch(headless=False,
args=args)
context = await browser.new_context()
page = await context.new_page()
await page.goto("https://raw.githack.com/microsoft/playwright-python/main/tests/assets/empty.html")
await page.set_content('<a href="https://raw.githack.com/microsoft/playwright-python/main/tests/assets/one-style.html">yo</a>')
await page.click("a")
await page.wait_for_timeout(10000)
async def main():
async with async_playwright() as playwright:
await run(playwright)
if __name__ == "__main__":
loop = asyncio.ProactorEventLoop()
loop.run_until_complete(main())
Expected
The Selector should be able to pick up the new inserted content, like it is the case with "normal" playwright.
Actual
The Selector doesnt pick up the new content.
Note: Could be explained by a missing isolatedContext consideration.
Note:
await page.locator("a").click()
Works as expected.
Note no.1:
await page.set_content('<iframe src="demo_iframe.htm" height="200" width="300" title="Iframe Example"></iframe> ')
print(page.frame_locator('[title="Iframe Example"]'))
Also doesnt work. Other Functions including Selectors maight also not be expected to work
relevant source code here:
- NodeJS/
Frame. SetContent
undetected-playwright-python/playwright/_impl/_page.py
Lines 458 to 464 in c34fd89
and locator source:
undetected-playwright-python/playwright/_impl/_page.py
Lines 732 to 746 in c34fd89
undetected-playwright-python/playwright/_impl/_locator.py
Lines 146 to 159 in c34fd89
undetected-playwright-python/playwright/_impl/_page.py
Lines 677 to 691 in c34fd89
undetected-playwright-python/playwright/_impl/_frame.py
Lines 469 to 483 in c34fd89