Selenium: Undefined method `log` for Selenium::WebDriver::Remote::W3C::Bridge

Created on 27 Nov 2017  Â·  9Comments  Â·  Source: SeleniumHQ/selenium

Meta -

OS: macOS 10.13.1 (17B48)
Selenium Version: selenium-webdriver 3.7.0
GeckoDriver Version: 0.19.1
Browser: Firefox
Browser Version: 57.0

Expected Behavior -

I am able to access the JavaScript console logs.

Actual Behavior -

An exception is raised:

Exception: NoMethodError: undefined method `log' for #<Selenium::WebDriver::Remote::W3C::Bridge:0x007f9e66d31dd0>
--
 0: .../gems/selenium-webdriver-3.7.0/lib/selenium/webdriver/common/logs.rb:30:in `get'

Steps to reproduce -

repro.rb

require 'rubygems'
require 'webdrivers'
require 'selenium-webdriver'

driver = Selenium::WebDriver.for :firefox
driver.get "http://google.com"

errors = driver.manage.logs.get(:browser)
puts errors

driver.quit

Gemfile

# frozen_string_literal: true
source "https://rubygems.org"

gem "webdrivers", '3.2.2'
gem "selenium-webdriver", '3.7.0'
bundle exec ruby ./repro.rb

Most helpful comment

@sdhull I did not. I think you wish to follow https://github.com/mozilla/geckodriver/issues/284.

All 9 comments

That endpoint isn't in the w3c and likely won't be supported by Firefox.
To get browser/driver logs for Firefox, set it in the capabilities:
http://www.rubydoc.info/gems/selenium-webdriver/3.7.0/Selenium/WebDriver/Firefox/Options
what is available is here:
https://github.com/mozilla/geckodriver#log-object

@titusfortner thank you. Both of your links seem to be about how to set the logging level; I'm missing how to actually programmatically retrieve the logs. Any hints?

I think that mozilla/geckodriver#284 is the issue you refer to with "likely won't be supported by Firefox"

You may also want to close #1161 then?

@shepmaster you don't see it in STDOUT?

@titusfortner @shepmaster is referring to the browser console logs, which are not supported by gecko/firefox at this time as the spec does not define them. It is a possibility for the future.

@lmtierney is correct — I want to add assertions to my tests that no console warnings were logged during the run. Thank you both for your help!

@shepmaster did you find a solution to accomplish this? I want to do the same.

@sdhull I did not. I think you wish to follow https://github.com/mozilla/geckodriver/issues/284.

Was this page helpful?
0 / 5 - 0 ratings