在Ubuntu服务器上更新到chromedriver 76.0后,测试执行速度变慢

时间:2019-08-12 13:21:28

标签: c# ubuntu selenium-chromedriver

我的测试在chromedriver 74.0和chrome 74上运行良好,但是如果我将两者都更新到版本76,则执行时间将从大约15秒增加到1分钟。

  • 测试以无头模式运行
  • Ubuntu 16.04.6
  • 谷歌浏览器76.0.3809.100
  • chromedriver 76.0.3809.68

我使用以下代码设置了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秒左右

0 个答案:

没有答案