Home >Backend Development >Python Tutorial >How to Eliminate the Persistent .exe File When Running ChromeDriver in Headless Mode?
Configuring ChromeDriver to Initiate Chrome Browser in Headless Mode
Problem Statement:
To enhance the performance of a web-scraping script using Python and ChromeDriver, the user desires to operate it in headless mode to eliminate pop-up browser windows. While setting the 'headless' option on ChromeDriver prevents browser windows from appearing, the .exe file remains visible.
Solution:
To configure ChromeDriver to initiate Chrome browser in headless mode, utilize the following code:
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument('--headless') options.add_argument('--disable-gpu') # May be necessary. driver = webdriver.Chrome(CHROMEDRIVER_PATH, chrome_options=options)
Explanation:
This code accomplishes the following:
The suggested modification should eliminate the persistent .exe file visibility and ensure that ChromeDriver operates solely in headless mode.
The above is the detailed content of How to Eliminate the Persistent .exe File When Running ChromeDriver in Headless Mode?. For more information, please follow other related articles on the PHP Chinese website!