Enable execute_cdp for webdriver.Remote ?

See original GitHub issue

🚀 Feature Proposal

Can we enable execute_cdp for driver instance from webdriver.Remote()? currently we are getting an Attribute Error for the following

Requiremnts

Python 3.6.9
selenium 3.141.0
from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--no-sandbox")
driver = webdriver.Remote( 
  command_executor='https://remote/webdriver', 
  desired_capabilities=chrome_options.to_capabilities() 
)
driver.execute_cdp_cmd("execute something")

AttributeError: 'WebDriver' object has no attribute 'execute_cdp_cmd'

Motivation

Already execute_cdp_cmd is availbe for selenium.webdriver.chrome.webdriver https://www.selenium.dev/selenium/docs/api/py/webdriver_chrome/selenium.webdriver.chrome.webdriver.html#selenium.webdriver.chrome.webdriver.WebDriver.execute_cdp_cmd

Example

driver.execute_cdp_cmd(“execute something”)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
oddmariocommented, Sep 28, 2020

A workaround would be using this function:

import json

def send(driver, cmd, params={}):
  resource = "/session/%s/chromium/send_command_and_get_result" % driver.session_id
  url = driver.command_executor._url + resource
  body = json.dumps({'cmd': cmd, 'params': params})
  response = driver.command_executor._request('POST', url, body)
  return response.get('value')

source: https://stackoverflow.com/a/47298910/8524395

6reactions
samkotlovecommented, Feb 9, 2021

Closing this as the new mechanisms for using CDP are available to remote. We won’t be adding this command as it was a workaround by the Chrome team

@AutomatedTester Could you point to where that is? Having trouble finding the python definition

Read more comments on GitHub >

github_iconTop Results From Across the Web

Selenium Chrome DevTools Protocol (CDP) API - Applitools
The executeCdpCommand() method is available directly from ChromiumDriver (and its descendent classes). The purpose of this method is to allow ...
Read more >
Chrome DevTools - Selenium
While Selenium 4 provides direct access to the Chrome DevTools Protocol (CDP), ... Emulate Geo Location with the Remote WebDriver:.
Read more >
CDP with Remote webdriver. 'WebDriver' object has no ...
I'm trying to run tests with CDP, webdriver.execute_cdp_cmd('Network.enable' ...
Read more >
New Feature Selenium 4 Chrome DevTools Protocol For ...
Selenium 4 Grid Tutorial with examples - Parallel execution in Remote Machines · Selenium GRID on Machines/Cloud/VMs/Docker/BrowserStack/ ...
Read more >
How To Use Chrome DevTools Protocol (CDP) In Selenium 4
Are you aware of the “Pin Script” feature in Selenium 4? If not, then this video is for you as it gives an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found