SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.59k stars 8.17k forks source link

[🐛 Bug]: undefined method `execute_cdp' on latest ChromeDriver 120.0.6099.71 #13319

Closed paulhan221 closed 10 months ago

paulhan221 commented 10 months ago

What Happened?

After updating chromedriver to the latest version (120.0.6099.71) via brew upgrade chromedriver the method execute_cdp is undefined.

How can we reproduce the issue?

In Ruby

  def allow_clipboard_read
    read_params = {
      origin: page.server_url,
      permission: { name: 'clipboard-read' },
      setting: 'granted'
    }
    write_params = {
      origin: page.server_url,
      permission: { name: 'clipboard-write' },
      setting: 'granted'
    }
    page.driver.browser.execute_cdp('Browser.setPermission', **read_params)
    page.driver.browser.execute_cdp('Browser.setPermission', **write_params)
  end

What browsers and operating systems are you seeing the problem on?

Chrome: Version 120.0.6099.109 (Official Build) (x86_64)

ChromeDriver: 120.0.6099.71

Operating Systems: Was able to replicate on both Mac & Ubuntu

github-actions[bot] commented 10 months ago

@paulhan221, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

titusfortner commented 10 months ago

What's the error / stack trace What options are you sending to the driver? Are you running headless?

paulhan221 commented 10 months ago

Hi @titusfortner thank you for the response! Stack trace:

     NoMethodError:
       undefined method `execute_cdp' for #<Selenium::WebDriver::Chrome::Driver:0x..faa6e02729f534fa6 browser=:"chrome-headless-shell">

           page.driver.browser.execute_cdp('Browser.setPermission', **read_params)
                              ^^^^^^^^^^^^
       Did you mean?  execute_script

     [Screenshot Image]: /Users/name/dev/appity/st/tmp/screenshots/failures_r_spec_example_derp_287.png

     # ./spec/system/derp_spec.rb:76:in `allow_clipboard_read'
     # ./spec/system/derp_spec.rb:29:in `block (2 levels) in <top (required)>'
     # /Users/name/.rvm/gems/ruby-3.1.2/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:124:in `block in run'
     # /Users/name/.rvm/gems/ruby-3.1.2/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:110:in `loop'
     # /Users/name/.rvm/gems/ruby-3.1.2/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:110:in `run'
     # /Users/name/.rvm/gems/ruby-3.1.2/gems/rspec-retry-0.6.2/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
     # ./spec/rails_helper.rb:120:in `block (2 levels) in <top (required)>'
     # /Users/name/.rvm/gems/ruby-3.1.2/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:124:in `block in run'
     # /Users/name/.rvm/gems/ruby-3.1.2/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:110:in `loop'
     # /Users/name/.rvm/gems/ruby-3.1.2/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:110:in `run'
     # /Users/name/.rvm/gems/ruby-3.1.2/gems/rspec-retry-0.6.2/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
     # /Users/name/.rvm/gems/ruby-3.1.2/gems/rspec-retry-0.6.2/lib/rspec/retry.rb:37:in `block (2 levels) in setup'

Running headless. Options are:

Capybara.register_driver :selenium_chrome_headless do |app|
    options = ::Selenium::WebDriver::Chrome::Options.new

    options.add_argument('--headless')
    options.add_argument('--no-sandbox')
    options.add_argument('--window-size=1400,1400')
    options.add_argument('--disable-dev-shm-usage')
    options.add_argument('--disable-gpu')

    Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
  end
titusfortner commented 10 months ago

Ok thought so. Change to --headless=new and it will work. Google changed the name of the old headless since it isn't actually chrome. Support for old headless will be in 4.17

paulhan221 commented 10 months ago

@titusfortner Thank you!

github-actions[bot] commented 9 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.