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

*爱你&永不变心* 提交于 2019-12-13 09:38:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!