我在运行测试时沉默Chrome驱动程序控制台输出 [英] Silencing Chrome driver console outputs when I run my tests

查看:103
本文介绍了我在运行测试时沉默Chrome驱动程序控制台输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用最新版本的Chrome(32.0.1700.107)和Chrome驱动程序(V2.8)。但是当我在Ruby中使用以下代码运行样本测试时:

 需要'selenium-webdriver'
WAIT = Selenium :: WebDriver :: Wait.new(timeout:100)
$ driver = Selenium :: WebDriver.for:chrome
$ driver.manage.window.maximize
$ driver.navigate.to 'https://www.google.co.in'

def apps_hover
ele_hover = $ driver.find_element(:xpath,.//*[@id='gbwa'] / div [1] / a)
$ driver.action.move_to(ele_hover).perform
sleep 5
putsPass
end

apps_hover
$ driver.quit()

我从chrome驱动程序的控制台输出如下所示:
$ b

[5032:4816:0218/130016:错误:chrome_views_delegate.cc(176)]未执行
[5032:4816:0218 /130016:ERROR:desktop_root_window_host_win.cc(746)] NOT IMPLEMENTED
[5032:4816:0218/130016:ERROR:desktop_root_window_host_win.cc(746)]未实现。



有没有办法让这些控制台输出无声?

解决方案

我还没有找到办法直接沉默铬司机警告。然而,你可以很容易地编写一个过滤器脚本,它可以处理每行输出,并将这些行从STDOUT或STDERR中排除(取决于它们以何种方式发送)。

以红宝石处理STDIN的最佳实践


I am using latest versions of Chrome(32.0.1700.107) and Chrome driver(V2.8). But when I run my sample test with following code in Ruby:

    require 'selenium-webdriver'
    WAIT = Selenium::WebDriver::Wait.new(timeout: 100)
    $driver = Selenium::WebDriver.for :chrome
    $driver.manage.window.maximize
    $driver.navigate.to 'https://www.google.co.in'

     def apps_hover
      ele_hover = $driver.find_element(:xpath, ".//*[@id='gbwa']/div[1]/a")
      $driver.action.move_to(ele_hover).perform
      sleep 5
      puts"Pass"
     end

     apps_hover
    $driver.quit()

I get the console output from chrome driver at the beginning like following :

[5032:4816:0218/130016:ERROR:chrome_views_delegate.cc(176)] NOT IMPLEMENTED [5032:4816:0218/130016:ERROR:desktop_root_window_host_win.cc(746)] NOT IMPLEMENTED [5032:4816:0218/130016:ERROR:desktop_root_window_host_win.cc(746)] NOT IMPLEMENTED.

Is there a way to silence these console outputs?

解决方案

I haven't found a way to silence chrome driver warnings directly. You can however write a filter script fairly easily which processes each line of output and excludes these lines from STDOUT or STDERR (depending on which way they are being sent).

Related: Best practices in dealing with STDIN in ruby

这篇关于我在运行测试时沉默Chrome驱动程序控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆