how to stop selenium chromedriver from logging to the screen

雨燕双飞 提交于 2019-12-13 16:16:25

问题


How do I stop selenium chromedriver from logging errors to the screen?

I am running some cucumber tests and Im using capybara & the selenium chromedriver to drive the tests. In the last few weeks ive noticed that the Chromedriver has started logging its error messages to the screen. My tests still run fine but the errors are clogging up the output.

This is the output below:

Started ChromeDriver
port=9515
version=23.0.1240.0
log=C:\Gitrepos\Base Tests\chromedriver.log
[8244:5080:1115/151428:ERROR:gpu_info_collector_win.cc(91)] Can't retrieve a valid WinSAT assessment.
    Given I Select "Customer" from the "Search" gadget
    And I enter "Test Customer" for "Customer Name"
    And click "Search"
    And Select "Manage Customer" from the "Main Menu" drop down

The solution would be to remove the following line from the output or possibly to fix the error. [8244:5080:1115/151428:ERROR:gpu_info_collector_win.cc(91)] Can't retrieve a valid WinSAT assessment.

I upgraded the driver to fix a different error but I ended up getting this error!


回答1:


Try to start the Chromedriver using a redirect of STDERR, e.g.

chromedriver.exe 2>c:\temp\err.log




回答2:


I had the same problem, here is what suppressed all those chrome messages (chrome prints a few sorts.. ):

    ChromeOptions chromeOptions = setupChromeOptions();
    System.setProperty("webdriver.chrome.logfile", "\\path\\chromedriver.log");
    System.setProperty("webdriver.chrome.driver", "\\path\\chromedriver.exe");
    System.setProperty("webdriver.chrome.args", "--disable-logging");
    System.setProperty("webdriver.chrome.silentOutput", "true");
    driver = new ChromeDriver(chromeOptions);

This works for me with the following config

  selenium-chrome-driver-2.48.2.jar
  chromedriver 2.20
  selenium-java-2.48.2.jar


来源:https://stackoverflow.com/questions/13400765/how-to-stop-selenium-chromedriver-from-logging-to-the-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!