且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在使用chrome canary执行selenium python脚本时抑制控制台错误/警告/信息消息

更新时间:2023-10-20 13:34:58

尝试options.add_argument('log-level = 3')。

log-level:
设置最小日志级别。
有效值从0到3:

  INFO = 0,
WARNING = 1,
LOG_ERROR = 2,
LOG_FATAL = 3.

默认为0。


I am running python script (complete script link below) for selenium test using Chrome Canary. The test seems to be running fine, however, there are lots of error/warning/info messages displayed on the console.

Is there a way to suppress these messages? I have tried: chrome_options.add_argument("--silent"), but does not help. I am not able to find the right solution. Appreciate any help.

Python script : Example script provided here

Python: 3.6.3 Selenium: 3.6.0 Chrome Canary: 63.0.3239.5 (64 bit) ChromeDriver : 2.33

Try options.add_argument('log-level=3').

log-level: Sets the minimum log level. Valid values are from 0 to 3:

INFO = 0, 
WARNING = 1, 
LOG_ERROR = 2, 
LOG_FATAL = 3.

default is 0.