Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cromedriver `driver.manage.logs.get(:browser)` fails on chromedriver 75.0.3770.8

While accessing driver.manage.logs.get(:browser) on chromedriver 75.0.3770.8 - it cause error

undefined method `log' for # (NoMethodError)

Works fine on 74.0.3729.6

from: https://github.com/SeleniumHQ/selenium/issues/7270

like image 547
Daniel Avatar asked Jun 10 '19 07:06

Daniel


People also ask

What is WebDriver driver ChromeDriver?

WebDriver is an open source tool for automated testing of webapps across many browsers. It provides capabilities for navigating to web pages, user input, JavaScript execution, and more. ChromeDriver is a standalone server that implements the W3C WebDriver standard.


2 Answers

Chrome 75 defaults to W3C mode, which doesn't specify a way to get log access.

The short term fix for this issue is to disable w3c via chromeOptions.

Capybara.register_driver :headless_chrome do |app|
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    chromeOptions: { args: %w[headless window-size=1280,800], w3c: false },
  )

  Capybara::Selenium::Driver.new app,
                                 browser: :chrome,
                                 desired_capabilities: capabilities
end
like image 97
Daniel Avatar answered Oct 29 '22 20:10

Daniel


in recent selenium-webdriver (4.4.0) with recent Chrome (105), manage.logs is gone but this works:

page.driver.browser.logs.get(:browser)
like image 8
Janosch Avatar answered Oct 29 '22 18:10

Janosch