我的测试在chromedriver 74.0和chrome 74上运行良好,但是如果我将两者都更新到版本76,则执行时间将从大约15秒增加到1分钟。
我使用以下代码设置了chromedriver
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.Warning);
chromeOptions.AddExcludedArgument("--ignore-certificate-errors");
chromeOptions.AddExcludedArgument("--disable-threaded-compositing");
chromeOptions.AcceptInsecureCertificates = true;
chromeOptions.AddUserProfilePreference("intl.accept_languages", m_BrowserAcceptedLanguage);
chromeOptions.AddArguments("--lang=" + m_BrowserAcceptedLanguage);
chromeOptions.AddUserProfilePreference("safebrowsing.enabled", "true");
chromeOptions.AddArguments("--proxy-server='direct://'");
chromeOptions.AddArguments("--proxy-bypass-list=*");
chromeOptions.AddArguments("--no-proxy-server");
chromeOptions.AddArguments("--proxy-server=");
chromeOptions.AddArguments(
"blacklist-accelerated-compositing",
"disable-accelerated-2d-canvas",
"disable-accelerated-compositing",
"disable-accelerated-layers",
"disable-accelerated-plugins",
"disable-accelerated-video",
"disable-accelerated-video-decode");
chromeOptions.Proxy = null;
chromeOptions.AddArguments("--disable-extensions");
chromeOptions.AddAdditionalCapability("useAutomationExtension", false);
if (m_UseCustomUserAgent && !string.IsNullOrEmpty(m_CustomUserAgent))
{
chromeOptions.AddArgument($"--user-agent={m_CustomUserAgent}");
}
if (m_DisableGeoLocation)
{
chromeOptions.AddUserProfilePreference("profile.default_content_settings.geolocation", 2);
chromeOptions.AddUserProfilePreference("profile.default_content_setting_values.geolocation", 2);
}
if (!string.IsNullOrEmpty(m_SetDownloadFolder))
{
chromeOptions.AddUserProfilePreference("profile.default_content_settings.popups", 0);
chromeOptions.AddUserProfilePreference("profile.default_content_setting_values.popups", 0);
chromeOptions.AddUserProfilePreference("profile.default_content_setting_values.automatic_downloads", 1);
chromeOptions.AddUserProfilePreference("download.default_directory", m_SetDownloadFolder);
}
chromeOptions.AddArguments("--headless");
ChromeDriverService chromeService = ChromeDriverService.CreateDefaultService(Environment.CurrentDirectory);
chromeService.HideCommandPromptWindow = true;
Instance = new ChromeDriver(chromeService, chromeOptions, DefaultCommandTimeout);
我希望将执行时间减少到15秒左右