kaliiiiiiiiii / undetected-playwright-python

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

[BUG] (Action) Selectors do not Work after Manual Content Setting #7

Open Vinyzu opened 9 months ago

Vinyzu commented 9 months ago

Source code

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.

Vinyzu commented 9 months ago

Note:

await page.locator("a").click()

Works as expected.

Vinyzu commented 9 months ago

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

kaliiiiiiiiii commented 9 months ago

relevant source code here:

kaliiiiiiiiii commented 9 months ago

and locator source: