Get Chromes Console Log via Ruby Webdriver

Get chromes console log via Ruby WebDriver

Apologies for late response.

I originally achieved it by adding the following to Webdriver;

module Selenium
module WebDriver
class Options

#
# Returns the available logs for this webDriver instance
#
def available_log_types
@bridge.getAvailableLogTypes
end

#
# Returns the requested log
#
# @param type [String] The required log type
#
# @return [Array] An array of log entries
#
def get_log(type)
@bridge.getLog(type)
end

end
end
end

When "required" this resulted in the following being supported;

driver.manage.get_log(:browser)

However, Version 2.38 of the selenium ruby gem exposes the logging API (although experimental).

http://selenium.googlecode.com/git/rb/CHANGES

https://code.google.com/p/selenium/wiki/Logging

Therefore, from 2.38 onwards the following should work WITHOUT the above extension;

driver.manage.logs.get :browser

Check browser console output on Ruby

Version 2.38 of the selenium ruby gem exposes the logging API.

http://selenium.googlecode.com/git/rb/CHANGES

This allows you to access the chrome console logs.

https://code.google.com/p/selenium/wiki/Logging

Here is an example in Java but you should be able to translate easily to ruby;

java example

Enable/view console.log messages in headless Chrome

When Chrome changed to w3c mode by default (v75) it changed loggingPrefs to goog:loggingPrefs to be spec compliant. Try setting goog:loggingPrefs instead.

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

Capybara 3.24 now works around this issue when used with chromedriver >= 75.0.3770.90



Related Topics



Leave a reply



Submit