private static void SetupChromiumOptions(ChromiumOptions options, bool silentMode) { options.AddArgument("disable-infobars"); options.AddArgument("--disable-bundled-ppapi-flash"); options.AddArgument("--log-level=3"); options.AddArgument("--silent"); if (silentMode) { options.AddArgument("--headless"); } options.AddUserProfilePreference("credentials_enable_service", false); options.AddUserProfilePreference("profile.password_manager_enabled", false); options.AddUserProfilePreference("auto-open-devtools-for-tabs", false); }
private static void SetupChromiumOptions(ChromiumOptions options, bool silentMode, List <object> chromeSwitches = null, Dictionary <string, bool> chromeProfiles = null, int chromePort = 0, bool chromeAttach = false) { if (chromeAttach) { if (chromePort != 0) { options.DebuggerAddress = $"localhost:{chromePort}"; } else { throw new ApplicationException("Bad arguments. Expected ChromePort != 0"); } } else { options.AddArgument("disable-infobars"); options.AddArgument("--disable-bundled-ppapi-flash"); options.AddArgument("--log-level=3"); options.AddArgument("--silent"); if (silentMode) { options.AddArgument("--headless"); } options.AddUserProfilePreference("credentials_enable_service", false); options.AddUserProfilePreference("profile.password_manager_enabled", false); options.AddUserProfilePreference("auto-open-devtools-for-tabs", false); if (chromePort != 0) { options.AddArgument($"--remote-debugging-port={chromePort}"); } } if (chromeSwitches != null) { foreach (var argument in chromeSwitches) { if (argument != null) { options.AddArgument(argument?.ToString()); } } } if (chromeProfiles != null) { foreach (var profile in chromeProfiles) { options.AddUserProfilePreference(profile.Key, profile.Value); } } }