Kaliiiiiiiiii-Vinyzu / CDP-Patches

Patching CDP (Chrome DevTools Protocol) leaks on OS level. Easy to use with Playwright, Selenium, and other web automation tools.
https://vinyzu.gitbook.io/cdp-patches-documentation
GNU General Public License v3.0
63 stars 3 forks source link

[BUG] undetected_playwright is not supported. #12

Open HistoriFy opened 2 months ago

HistoriFy commented 2 months ago

Describe the bug

undetected_playwright is not supported. Normal playwright does have import, but not undetected_playwright. Throws TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union again.

Code Sample

#undetected_playwright import
from undetected_playwright.sync_api import sync_playwright
from cdp_patches.input import SyncInput
import requests
import csv

def get_locator_pos(locator):
    bounding_box = locator.bounding_box()
    assert bounding_box

    x, y, width, height = bounding_box.get("x"), bounding_box.get("y"), bounding_box.get("width"), bounding_box.get("height")
    assert x and y and width and height

    x, y = x + width // 2, y + height // 2
    return x, y

with sync_playwright() as p:
    args = []
    args.append("--disable-blink-features=AutomationControlled")

    browser = p.chromium.launch(headless=False, args=args)
    page = browser.new_page()
    sync_input = SyncInput(browser=browser)

    page.goto("any page")

    verify_element = page.locator('any element locator')  
    x, y = get_locator_pos(verify_element)
    sync_input.click("left", x, y)

    browser.close()

To Reproduce

Steps to reproduce the behavior:

  1. Just install undetected_playwright. Use it to open any website.
  2. Use cdp-patches.
  3. Run the code.
  4. See error.

Expected behavior

There is no import for undetected_playwright for sync as well as async https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches/blob/602b680abf50b8190a5955ec7feb8c2045002e8d/cdp_patches/input/browsers.py#L14

Screenshots

None

Desktop (please complete the following information):

Additional context None

cod888 commented 1 month ago

The same error exists when using SeleniumBase as well.