kaliiiiiiiiii / undetected-playwright-python

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

[BUG] Leaking CDP Runtime Domain on Persistent Context #3

Closed Vinyzu closed 9 months ago

Vinyzu commented 10 months ago

Source code

Test file (self-contained)

from tempfile import TemporaryDirectory

from playwright.sync_api import sync_playwright

temp_dir = TemporaryDirectory()
temp_dir_path = temp_dir.name

with sync_playwright() as p:
    args = ["--disable-blink-features=AutomationControlled"]
    browser = p.chromium.launch_persistent_context(user_data_dir=temp_dir_path, args=args, headless=False, channel="chrome")
    page = browser.new_page()
    page.goto("https://hmaker.github.io/selenium-detector/")
    input("Press ENTER to exit:")
    browser.close()

temp_dir.cleanup()

Steps

Expected

Should not have any Detection, as its the case without a Persistent Context.

Actual

The CDP Runtime Domain leaks and gets detected,

kaliiiiiiiiii commented 9 months ago

Can't really reproduce that - at least not with the runtime domain. image

what I did forget indeed is ignoreDefaultArgs=['--enable-automation'] for it, but added it now (=> next release)

soo with that fixed, the following script works just fine for me:

import time
from tempfile import TemporaryDirectory

from undetected_playwright.sync_api import sync_playwright

temp_dir = TemporaryDirectory()
temp_dir_path = temp_dir.name

with sync_playwright() as p:
    args = ["--disable-blink-features=AutomationControlled"]
    browser = p.chromium.launch_persistent_context(user_data_dir=temp_dir_path, args=args, headless=False, channel="chrome")
    page = browser.new_page()
    page.goto("https://nowsecure.nl/#relax")
    input()
    browser.close()

temp_dir.cleanup()
kaliiiiiiiiii commented 9 months ago

@Vinyzu Please test this again with https://pypi.org/project/undetected-playwright-patch/1.40.0.post1700587210000/ and close this issue if it's resolved now:)