我尝试过:
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()
但是它没有关闭控制台日志/ cmd.exe
答案 0 :(得分:0)
您无法将其完全隐藏在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.
答案 1 :(得分:-2)
#Combine this two options:
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
options = Options()
options.add_argument('--log-level=3')
dc = DesiredCapabilities.CHROME
dc['loggingPrefs'] = {'driver': 'OFF', 'server': 'OFF', 'browser': 'OFF'}
self.driver = webdriver.Chrome(chrome_options=options, desired_capabilities=dc, executable_path="C:\\path\\chromedriver.exe")