WebDriverManager.Net: [🐛 Bug]: WebDriverManager.Net not working with new chromedriver endpoints for Chrome since version 115

Problem

After updatating Chrome to version 115 the code below:

new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);

finishes with error:

System.Net.WebException
The remote server returned an error: (404) Not Found.
   at System.Net.HttpWebRequest.GetResponse()
   at WebDriverManager.DriverConfigs.Impl.ChromeConfig.GetLatestVersion(String url)
   at WebDriverManager.DriverConfigs.Impl.ChromeConfig.GetMatchingBrowserVersion()
   at WebDriverManager.DriverManager.GetVersionToDownload(IDriverConfig config, String version)
   at WebDriverManager.DriverManager.SetUpDriver(IDriverConfig config, String version, Architecture architecture)

Looks like there are changes for downloading chromedriver since v115 https://chromedriver.chromium.org/downloads “If you are using Chrome version 115 or newer, please consult the Chrome for Testing availability dashboard. This page provides convenient JSON endpoints for specific ChromeDriver version downloading.”

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 13
  • Comments: 42 (4 by maintainers)

Commits related to this issue

Most upvoted comments

If you can (temporarily) live with the latest chrome version, just change the ResolveStrategy to ‘Latest’. Then it will works fine.

    return new WebDriver
    {
        BrowserName = Browsers.Chrome,
        Driver = new ChromeDriver(
            Path.GetDirectoryName(new DriverManager().SetUpDriver(new ChromeConfig(),
                VersionResolveStrategy.Latest)), // <= no problem with 'Latest'
            options)
    };

We temporarily patched our systems by adding an override for the GetMatchingBrowserVersion with a quick chrome 115 version check to redirect the URL.


public partial class ChromeConfigOverride : ChromeConfig
{

    private const string BaseVersionPatternUrl = "https://chromedriver.storage.googleapis.com/<version>/";
    private const string LatestReleaseVersionUrl = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE";

    private const string ExactReleaseVersionPatternUrl =
        "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_<version>";

    public virtual string GetName()
    {
        return "Chrome";
    }

    public virtual string GetUrl32()
    {
        return GetUrl();
    }

    public virtual string GetUrl64()
    {
        return GetUrl();
    }

    private string GetUrl()
    {
#if NETSTANDARD
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                var architectureExtension =
                    RuntimeInformation.ProcessArchitecture == System.Runtime.InteropServices.Architecture.Arm64
                        ? "_arm64"
                        : "64";
                return $"{BaseVersionPatternUrl}chromedriver_mac{architectureExtension}.zip";
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                return $"{BaseVersionPatternUrl}chromedriver_linux64.zip";
            }
#endif

        return $"{BaseVersionPatternUrl}chromedriver_win32.zip";
    }

    public virtual string GetBinaryName()
    {
#if NETSTANDARD
            var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#else
        var isWindows = true;
#endif
        var suffix = isWindows ? ".exe" : string.Empty;
        return $"chromedriver{suffix}";
    }

    public virtual string GetLatestVersion()
    {
        return GetLatestVersion(LatestReleaseVersionUrl);
    }

    private static string GetLatestVersion(string url)
    {
        var uri = new Uri(url);
        var webRequest = WebRequest.Create(uri);
        using (var response = webRequest.GetResponse())
        {
            using (var content = response.GetResponseStream())
            {
                if (content == null) throw new ArgumentNullException($"Can't get content from URL: {uri}");
                using (var reader = new StreamReader(content))
                {
                    var version = reader.ReadToEnd().Trim();
                    return version;
                }
            }
        }
    }

    public virtual string GetMatchingBrowserVersion()
    {
        var rawChromeBrowserVersion = GetRawBrowserVersion();
        if (string.IsNullOrEmpty(rawChromeBrowserVersion))
        {
            throw new Exception("Not able to get chrome version or not installed");
        }

        var chromeBrowserVersion = VersionHelper.GetVersionWithoutRevision(rawChromeBrowserVersion);

        var url = ExactReleaseVersionPatternUrl.Replace("<version>", chromeBrowserVersion);
        Version chromeVersion = new Version(chromeBrowserVersion);

        if (chromeVersion >= new Version(115, 0, 0))
        {
            url = ExactReleaseVersionPatternUrl.Replace("<version>", @"https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/<version>/win32/chromedriver-win32.zip");
        }


        return GetLatestVersion(url);
    }

    private string GetRawBrowserVersion()
    {
#if NETSTANDARD
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                return RegistryHelper.GetInstalledBrowserVersionOsx("Google Chrome", "--version");
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                return RegistryHelper.GetInstalledBrowserVersionLinux(
                    "google-chrome", "--product-version",
                    "chromium", "--version",
                    "chromium-browser", "--version");
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return RegistryHelper.GetInstalledBrowserVersionWin("chrome.exe");
            }

            throw new PlatformNotSupportedException("Your operating system is not supported");
#else
        return RegistryHelper.GetInstalledBrowserVersionWin("chrome.exe");
#endif
    }

}

This workaround may help others so posting here

            var driverPath = new DriverManager().SetUpDriver(new ChromeConfig());
            driver = new ChromeDriver(driverPath);

Hey everyone, this issue should get resolved once a version is released containing #254 FYI - I think there may be another addition to this change where we need to look at applying the WithProxy settings to the ChromeForTestingClient.

@inflextion I have added a pull request now: #259

I use 2.17.1 and has the same problem after Chrome updated to 116. It works correctly before (115).

Probably, in the method WithProxy of the class DriverManager new you should set not only the default proxy of WebRequest but also of HttpClient, because in the class ChromeForTestingClient new the HttpClient is used.

If we set the default proxy of HttpClient, the exception described above will no longer occur.

public DriverManager WithProxy(IWebProxy proxy)
{
    _binaryService = new BinaryService
    {
        Proxy = proxy
    };
    WebRequest.DefaultWebProxy = proxy;
    // add this line here?
    HttpClient.DefaultProxy = proxy;
    return this;
}

If you debug and console log the URL that has been generated, then paste it here please?

[https://chromedriver.storage.googleapis.com/LATEST_RELEASE_115.0.5790]

Which returns

<Error> NoSuchKey <Message>The specified key does not exist.</Message>
No such object: chromedriver/LATEST_RELEASE_115.0.5790
</Error>

This is due to the changes that Google annoucned in May that would take effect with the 115 release and includes

The download location for ChromeDriver releases will change.

This applies to both the old ChromeDriver Stable + Beta downloads at https://chromedriver.storage.googleapis.com/ as well as the old Canary downloads at https://chromedriver.chromium.org/chromedriver-canary. We won’t publish new downloads to these locations in the future.

Here are the new end points

@stevekiszow

We moved to selenium 4 ‘built-in’ driver manager. It also have some issues in our test runs, but we fixed it on our side

FYI there is also issue for that in selenium 4 ‘buil-in’ driver manager https://github.com/SeleniumHQ/selenium/pull/12208

Hi folks, do we have a time frame for this issue? Just seeing this today also and wondering if there is a work around?