In debugging or performing automated regression tests locally , I don't want to occupy my precious screen because of the repeatedly opened browser , None at this time UI Testing is especially important , It's easy , Just add one line of code to solve this problem :
options.add_argument('--headless')
from selenium import webdriver
chromeDriverPath='E:\Tool\Python-3.8.2\chromedriver.exe' #chromedriver The path of
options = webdriver.ChromeOptions()
options.add_argument('--headless')
driver = webdriver.Chrome(executable_path=chromeDriverPath,chrome_options=options)
driver.get('http://www.baidu.com')
print('Open success!')
Running results ( There is no page display in the whole process ):