How to suppress console error/warning/info messages when executing selenium python scripts using chrome canary
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.
If "--log-level" doesn't work for you (as of 75.0.3770.100 it didn't for me), this should:
options = webdriver.ChromeOptions()options.add_experimental_option('excludeSwitches', ['enable-logging'])driver = webdriver.Chrome(executable_path='<path-to-chrome>', options=options)
see:
https://bugs.chromium.org/p/chromedriver/issues/detail?id=2907#c3
Works for me in Python/Chrome...
from selenium.webdriver.chrome.options import Optionschrome_options = Options()chrome_options.add_argument('--headless')chrome_options.add_argument('--log-level=3')