问题
How to hide cmd.exe/console log of chromedriver in selenium in python?
I tried:
driver.service.stop()
Full Code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
import time
print("Opening...")
driver = webdriver.Chrome()
driver.get('https://google.com')
driver.service.stop()
But it didn't close the console log/ cmd.exe
回答1:
You cannot hide it completely in Chrome driver but you can suppress few and set minimum log level as below:
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('log-level=2')
where log-level is
INFO = 0,
WARNING = 1,
LOG_ERROR = 2,
LOG_FATAL = 3.
来源:https://stackoverflow.com/questions/52223642/how-to-hide-cmd-exe-console-log-of-chromedriver-in-selenium-in-python