Reputation: 218
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 ?
Upvotes: 0
Views: 6026
Reputation: 11
The solution is setting the log level of selenium and the logging of the OS.
For windows:
options.add_argument('--log-level=3')
which will only tell you the warnings and errors related to selenium. And:
logging.disable(logging.CRITICAL)
will suppress all the logs by Windows. Here's how you can do it:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import logging
logging.disable(logging.CRITICAL)
options = Options()
options.add_argument('--log-level=3')
driver = webdriver.Chrome(options=options)
driver.get("https://www.google.com")
Upvotes: 0
Reputation: 79
This worked for me for webdriver_manager v3.8.3:
from webdriver_manager.core.logger import __logger as wdm_logger
wdm_logger.setLevel(logging.WARNING)
Upvotes: 0
Reputation: 66
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
Upvotes: 4
Reputation: 193058
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")
Upvotes: 2
Reputation: 15426
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.
Upvotes: 1
Reputation: 11
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)
Upvotes: 0