通过Ruby WebDriver获取Chrome控制台日志 [英] Get chromes console log via Ruby WebDriver
问题描述
此问题以前已经用Java回答过(获取chrome的控制台日志)
This question has been previously answered in Java (Get chrome's console log)
但是,我使用的是Ruby绑定,想知道它是否提供类似的功能?
However, I am using the Ruby bindings and was wondering if that provided similar functionality?
我看过Ruby源代码,但看不到任何提及或引用LoggingPreferences的内容.
I have looked at the Ruby source code but cannot see any mention or reference to LoggingPreferences.
顺便说一句,我正在使用RemoteWebDriver并传入所需的功能对象.大概我想在该对象中设置日志记录首选项,但是我在努力查看位置.
By the way, I am using RemoteWebDriver and passing in a desired capability object. Presumably I want to set the logging preferences in that object, but I am struggling to see where.
推荐答案
抱歉,请稍后回复.
我最初是通过将以下内容添加到Webdriver中来实现的;
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)
但是,硒红宝石宝石2.38版公开了日志记录API(尽管是实验性的).
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
因此,从2.38开始,以下功能应在没有上述扩展名的情况下起作用;
Therefore, from 2.38 onwards the following should work WITHOUT the above extension;
driver.manage.logs.get :browser
这篇关于通过Ruby WebDriver获取Chrome控制台日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!