此问题之前已在Java(
Get chrome’s console log)中得到解答
但是,我正在使用Ruby绑定,并想知道是否提供了类似的功能?
我查看了Ruby源代码,但看不到任何提及或引用LoggingPreferences.
顺便说一句,我正在使用RemoteWebDriver并传入所需的功能对象.据推测,我想在该对象中设置日志记录首选项,但我很难看到哪里.
解决方法
对迟到的回应道歉.
- 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
当“需要”时,这导致以下支持;
- driver.manage.get_log(:browser)
然而,2.38版的硒红宝石宝石暴露了测井API(虽然是实验性的).
http://selenium.googlecode.com/git/rb/CHANGES
https://code.google.com/p/selenium/wiki/Logging
因此,从2.38起,以下内容应在没有上述延期的情况下工作;
- driver.manage.logs.get :browser