rosolko / WebDriverManager.Net

Automatic Selenium Webdriver binaries management for .Net
MIT License
269 stars 83 forks source link

Added support for chrome for testing apis #254

Closed iouym closed 1 year ago

iouym commented 1 year ago

This PR adds support for the new Chrome for Testing API's, as a side-effect it resolves issues seen in #253 where versions of Chrome higher than or equal to 115.0.5763.0 would result in a 404 response when attempting to download the required chrome driver. I've also retained backwards compatibility with the older Chrome driver storage API's as older versions currently aren't supported by the Chrome for Testing API's.

This PR also fixes issues with downloading older versions of Chrome driver on ARM64 based machines, previously Chrome driver versions less than or equal to 106.0.5249.21 would fail to download due to the Chrome storage API's using the 64_m1 extension instead of the arm64 extension which has now been adopted since.

JDCain commented 1 year ago

Using .Result with HttpClient was causing deadlocks with parallel tests when I tried this code. I changed it to the following based on https://stackoverflow.com/a/53529122/4540638

private ChromeVersionInfo GetVersionFromChromeForTestingApi(string version)
{
    var task = Task.Run(() => _chromeForTestingClient.GetKnownGoodVersionsWithDownloads());
    task.Wait();
    var knownGoodVersions = task.Result;
    _chromeVersionInfo = knownGoodVersions.Versions.FirstOrDefault(cV => cV.Version == version);

    return _chromeVersionInfo;
}

I also made HttpClient static per https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use and I was able to use this successfully with xunit parallel testing selenium.

edit: I think I am running into issues with HttpClient not working with proxy correctly since it's not using the WithProxy settings

iouym commented 1 year ago

@JDCain I've applied some of those recommended fixes, thanks for that! :)

As for the WithProxy settings, I'll have to revise how this is built a little to cater for that use case

kieranedwards commented 1 year ago

Hi all, now that this PR has been merged, when does the updated package get published? Thank you!

praveenm-symplr commented 1 year ago

Hi all, now that this PR has been merged, when does the updated package get published? Thank you!

It has been released now! https://github.com/rosolko/WebDriverManager.Net/releases/tag/2.17.0