沉默ChromeDriver.exe日志记录

时间:2013-04-04 22:25:14

标签: webdriver watir watir-webdriver selenium-chromedriver

我正在使用watir-webdriver对Chrome运行ruby单元测试。每当运行测试并启动chromedriver.exe时,都会显示类似于下面的输出:

Started ChromeDriver
port=9515
version=26.0.1383.0
log=C:\Home\Server\Test\Watir\web\chromedriver.log
[5468:8796:0404/150755:ERROR:accelerated_surface_win.cc(208)] Reseting D3D device
[5468:8996:0404/150758:ERROR:textfield.h(156)] NOT IMPLEMENTED
[WARNING:..\..\..\..\flash\platform\pepper\pep_module.cpp(63)] SANDBOXED

这些都不会影响测试的正确运行,但正如人们可能想象的那样,“错误”和“警告”的出现可能会让人感到困惑,例如,在Jenkins中解析规则以寻找失败。当然,我可以在解析规则中使用正则表达式,但是在chromedriver.exe的部分关闭这个冗长和不必要的日志记录真的很好。我已经看到很多提到这个寻找答案的人。没人提出解决方案。是的,chromedriver可能有一个“--silent”选项,但似乎无法将其传递给可执行文件。类似于下面的代码应该起作用,但就我所见,它没有效果。有什么想法吗?

profile = Selenium::WebDriver::Chrome::Profile.new
profile['--cant-make-any-switches-work-here-how-about-you'] = true
browser = Watir::Browser.new :chrome, :profile => profile, :switches => %w[--ignore-certificate-errors --disable-extensions --disable-popup-blocking --disable-translate--allow-file-access]

4 个答案:

答案 0 :(得分:2)

这是其他任何人搜索的帮助

查找... selenium\webdriver\chrome\service.rb 路径启动可能与您的系统不同

我在传递的参数中添加了“-silent”....但是,除了错误/警告信息之外,这一切都沉默了。

    def initialize(executable_path, port)
      @uri           = URI.parse "http://#{Platform.localhost}:#{port}"
      server_command = [executable_path, " -silent", "--port=#{port}"]

      @process       = ChildProcess.build(*server_command)
      @socket_poller = SocketPoller.new Platform.localhost, port, START_TIMEOUT

      @process.io.inherit! if $DEBUG == true
    end

答案 1 :(得分:2)

chromeOptions设置为key --log-level=3,这应该将其关闭

答案 2 :(得分:1)

通过使用:service_log_path参数,我能够转移数百个,是数百个Chrome驱动程序日志消息,这些消息显示在黄瓜标准输出中。

@browser = Watir::Browser.new :chrome, :service_log_path => 'chromedriver.out'

上面建议的'-silent''--silent'或“-silent'' --silent'参数在我将其添加到...selenium\webdriver\chrome\service.rb时没有做任何事情。不得不调整宝石本身并不是一个特别可行的解决方案。

我找不到一个捕捉chromedriver stderr的地方并将其转移到null(更不用说必须在windows和* nix / osx中处理它)

驱动程序应默认为不那么冗长的东西。在这种情况下,INFO过于冗长,因为数百个日志条目作为INFO弹出,其中90%+相同。

至少:service_log_path参数适用于大部分。

答案 3 :(得分:0)

您可以尝试-Dwebdriver.chrome.logfile="/dev/null"和/或-Dwebdriver.chrome.args="--disable-logging"来运行selenium-server-standalone-what.ever.jar

的java选项
相关问题