'How to stop selenium from printing WebDriver manager startup logs?

When I'm launching a new selenium driver I get a message as:

====== WebDriver manager ======
Current chromium version is 90.0.4430
Get LATEST chromedriver version for 90.0.4430 chromium
Driver [/root/.wdm/drivers/chromedriver/linux64/90.0.4430.24/chromedriver] found in cache

I tryed using:

chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
chrome_options.add_argument('log-level=2')

But none worked.

Is there a better way ?



Solution 1:[1]

To silent webdrivermanager-python logs and remove them from console, you can initialize the env variable WDM_LOG_LEVEL with 0 value before your selenium tests as follows:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import os

os.environ['WDM_LOG_LEVEL'] = '0'
options = Options()
options.add_argument("start-maximized")
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get("https://www.google.com")

Solution 2:[2]

Are you using web driver manager? it looks like that is what is giving you logs (pip install webdriver-manager) . Im using selenium without web driver manager or adding any chrome options to remove logs , and not getting any logs printed.

also see :Turning off logging in Selenium (from Python)

Solution 3:[3]

The log-level that you are setting for chrome_options is completely separate from the logs that you are seeing from using the external library webdrivermanager for Python. That library will have its own way of disabling log messages (or at least it should). There are other Python libraries for managing WebDriver installs, such as SeleniumBase for example. Related, you might be able to change the Python logging level to hide that message, see Dynamically changing log level without restarting the application for details.

Solution 4:[4]

according to documents: just add below code into your files:

import os
os.environ['WDM_LOG'] = '0'

i have tried it with myself, working very well

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 undetected Selenium
Solution 2 01Cyber_cyber10
Solution 3 Michael Mintz
Solution 4