如何在python中的硒中隐藏chromedriver的cmd.exe/控制台日志? [英] How to hide cmd.exe/console log of chromedriver in selenium in python?

查看:320
本文介绍了如何在python中的硒中隐藏chromedriver的cmd.exe/控制台日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过:

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

But it didn't close the console log/ cmd.exe

推荐答案

您无法将其完全隐藏在Chrome驱动程序中,但是您可以取消隐藏它并设置最低日志级别,如下所示:

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')

日志级别为

INFO = 0, 
WARNING = 1, 
LOG_ERROR = 2, 
LOG_FATAL = 3.

这篇关于如何在python中的硒中隐藏chromedriver的cmd.exe/控制台日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆