我试过了:
driver.service.stop()
完整代码:
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()
但它没有关闭控制台log / cmd.exe
您无法在Chrome驱动程序中完全隐藏它,但您可以抑制少量并设置最低日志级别,如下所示:
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('log-level=2')
日志级别是
INFO = 0,
WARNING = 1,
LOG_ERROR = 2,
LOG_FATAL = 3.