Skip to content
Advertisement

How to stop selenium from printing webdriver-manager messages in python?

Each time that I initiate a new webdriver the following text is written to the console:

[WDM] - ====== WebDriver manager ======
[WDM] - Current google-chrome version is 102.0.5005
[WDM] - Get LATEST chromedriver version for 102.0.5005 google-chrome
[WDM] - Driver [C:Usersklaas.wdmdriverschromedriverwin32102.0.5005.61chromedriver.exe] found in cache

My goal was to stop selenium from printing this message to the console. Stack Overflow threads with similar topics to this one showed two options that did not work for me. The first one is:

from selenium.webdriver.chrome.options import Options

options = Options()
options.add_experimental_option("excludeSwitches", ["enable-logging"])
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)

and the second one is:

import logging
from selenium.webdriver.remote.remote_connection import LOGGER

LOGGER.setLevel(logging.WARNING)

Both of these solutions did work for some others but not for me. Is there some other way to stop selenium from printing webdriver messages?

Solution: As suggested by MohitC the following code prevented the webdriver-manager messages to be printed:

import logging
logging.getLogger('WDM').setLevel(logging.NOTSET)

Advertisement

Answer

These are webdriver-manager logs. You can either uninstall it if you are not using or disable logging as below

import os
os.environ['WDM_LOG'] = "false"

You can also try

import logging
logging.getLogger('WDM').setLevel(logging.NOTSET)
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement