Just a code snippet with a ChromeDriver configuration to run Chrome browser in a headless mode with the least possible amount of logging:
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.EnableVerboseLogging = false;
service.SuppressInitialDiagnosticInformation = true;
service.HideCommandPromptWindow = true;
ChromeOptions options = new ChromeOptions();
options.PageLoadStrategy = PageLoadStrategy.Normal;
options.AddArgument("--window-size=1920,1080");
options.AddArgument("--no-sandbox");
options.AddArgument("--headless");
options.AddArgument("--disable-gpu");
options.AddArgument("--disable-crash-reporter");
options.AddArgument("--disable-extensions");
options.AddArgument("--disable-in-process-stack-traces");
options.AddArgument("--disable-logging");
options.AddArgument("--disable-dev-shm-usage");
options.AddArgument("--log-level=3");
options.AddArgument("--output=/dev/null");
Browser = new ChromeDriver(service, options);
Explanation
EnableVerboseLogging
- false to disable verbose logging for the ChromeDriver executable.
SuppressInitialDiagnosticInformation
- when set to true the initial diagnostic information is suppressed when starting the driver server executable.
HideCommandPromptWindow
- the command prompt window of the service should be hidden.
PageLoadStrategy
- When set to PageLoadStrategy.Normar
driver waits for pages to load and ready state to be 'complete'.
Chrome browser arguments
This is the list of command-line arguments I use to get the best performance possible on Raspberry Pi 4. Full list of Chrome arguments.
--window-size=1920,1080
- set windows size to the specified values
--no-sandbox
- Disables sandbox mode for all processes
--headless
- Run in headless mode, i.e., without a UI or display server dependencies.
-disable-gpu
- Disables GPU hardware acceleration.
--disable-dev-shm-usage
- The /dev/shm partition is too small in certain VM environments, causing Chrome to fail or crash (see http://crbug.com/715363). Use this flag to work-around this issue (a temporary directory will always be used to create anonymous shared memory files).
--disable-crash-reporter
- Disable crash reporter for headless. It is enabled by default in official builds.
--disable-extensions
- Quite clear what it does ;)
--disable-in-process-stack-traces
- Disables the in-process stack traces.
--disable-logging
- logging should be already disabled in production builds, but better to double disable.
--log-level=3
- Sets the minimum log level. Valid values are from 0 to 3: INFO = 0, WARNING = 1, LOG_ERROR = 2, LOG_FATAL = 3