Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] undetected_playwright is not supported. #12

Open
HistoriFy opened this issue Jul 15, 2024 · 2 comments
Open

[BUG] undetected_playwright is not supported. #12

HistoriFy opened this issue Jul 15, 2024 · 2 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@HistoriFy
Copy link

HistoriFy commented Jul 15, 2024

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

from playwright.sync_api import Browser as SyncBrowser

Screenshots

None

Desktop (please complete the following information):

  • OS: Windows 10

Additional context
None

@HistoriFy HistoriFy added bug Something isn't working help wanted Extra attention is needed labels Jul 15, 2024
@cod888
Copy link

cod888 commented Jul 31, 2024

The same error exists when using SeleniumBase as well.

@Vinyzu Vinyzu self-assigned this Dec 13, 2024
@VTTR
Copy link

VTTR commented Feb 21, 2025

can confirm. happens also when using patchright-python

    sync_input = SyncInput(browser=browser)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\cdp_patches\input\sync_input.py", line 59, in __init__
    self.pid = get_sync_browser_pid(browser)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\cdp_patches\input\browsers.py", line 154, in get_sync_browser_pid
    if isinstance(browser, SeleniumChrome) or isinstance(browser, DriverlessSyncChrome):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants