如何在python中的selenium中隐藏chromedriver的cmd.exe / console日志?

问题描述 投票:-2回答:1

How to hide cmd.exe/console log of chromedriver in selenium in python?

我试过了:

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

python selenium selenium-webdriver cmd selenium-chromedriver
1个回答
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.
© www.soinside.com 2019 - 2024. All rights reserved.