Silencing Chrome driver console outputs when I run

2019-06-18 16:23发布

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?

1条回答
贼婆χ
2楼-- · 2019-06-18 16:46

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

查看更多
登录 后发表回答