kaliiiiiiiiii / CDP-Socket

socket for handling chrome-developer-protocol connections
MIT License
15 stars 3 forks source link

cdp_socket.socket self._ws has no attribute 'open' #30

Open Cvoluj opened 1 week ago

Cvoluj commented 1 week ago

Facing this error when trying create new_context in selenium_driverless

    if self._ws.open:
       ^^^^^^^^^^^^^
AttributeError: 'ClientConnection' object has no attribute 'open'

Tryed downgrading versions of cdp_socket and selenium_driverless, error still exist How to reproduce:

from selenium_driverless import webdriver
import asyncio

async def main():
    options = webdriver.ChromeOptions()
    async with webdriver.Chrome(options=options) as driver:
        context_1 = driver.current_context
        await context_1.get("chrome://extensions/")
        await asyncio.sleep(10)

        await driver.set_auth("username", "password", "localhost:5000")
        # proxy not supported on windows due to https://bugs.chromium.org/p/chromium/issues/detail?id=1310057
        context_2 = await driver.new_context()

        await context_1.current_target.get("https://examle.com")
        await context_2.get("https://examle.com")
        input("press ENTER to exit:)")

asyncio.run(main())

Versions:

selenium_driverless==1.9.4
websockets==14.1
cdp-socket==1.2.8
kaliiiiiiiiii commented 1 week ago

Relevant code here https://github.com/kaliiiiiiiiii/CDP-Socket/blob/4813479d7b856c4a609aa19e6fea80ed9d425445/src/cdp_socket/socket.py#L207 https://github.com/kaliiiiiiiiii/CDP-Socket/blob/4813479d7b856c4a609aa19e6fea80ed9d425445/src/cdp_socket/socket.py#L54

https://github.com/kaliiiiiiiiii/CDP-Socket/blob/4813479d7b856c4a609aa19e6fea80ed9d425445/src/cdp_socket/socket.py#L29

kaliiiiiiiiii commented 1 week ago

Couldn't find where this has changed, but guess it should be adapted to https://github.com/python-websockets/websockets/blob/59d4dcf779fe7d2b0302083b072d8b03adce2f61/src/websockets/sync/connection.py#L144