I'm trying to run tests with CDP,
webdriver.execute_cdp_cmd('Network.enable', {})
with Remote webdriver (in Selenoid). But getting this error:
AttributeError: 'WebDriver' object has no attribute 'execute_cdp_cmd'. In local environment it works fine. I've tried to use Selenium 3.141.0 and 4.1.3.
I'm familiar with PyCDP documentation (https://py-cdp.readthedocs.io/en/latest/getting_started.html) but I didn't figured out how to properly use it.
Why it does not work with Remote webdriver? Do someone have an example of executing CDP commands using python in Selenium 4?
I use following capabilities, :
capabilities = { 'loggingPrefs': {'browser': 'ALL'}, 'goog:loggingPrefs': {'performance': 'ALL'}, "browserName": "chrome", "browserVersion": "99.0", "selenoid:options": { "enableVNC": True, "enableVideo": False } }
if request.config.getoption('--remote'): driver = webdriver.Remote(command_executor='selenoid.dev:4444/wd/hub', desired_capabilities=capabilities, options=options)
The official way to use CDP in Python's Selenium library is to use bidirectional functionality
It's an asyncio API. However, you can turn it into a sync API by using trio. I use a wrapper function to make it easier to use.