diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index 7b95ffa..bc37499 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -15,7 +15,7 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
- 3.1.x
+ 7.0.x
9.0.x
- name: Restore dependencies
run: dotnet restore
@@ -23,7 +23,7 @@ jobs:
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-restore --no-build
-
+
deploy:
needs: build
runs-on: ubuntu-latest
diff --git a/WebDriverManager.Tests/ChromeConfigTests.cs b/WebDriverManager.Tests/ChromeConfigTests.cs
index efe4f26..9c3d8fa 100644
--- a/WebDriverManager.Tests/ChromeConfigTests.cs
+++ b/WebDriverManager.Tests/ChromeConfigTests.cs
@@ -24,10 +24,16 @@ public void DriverDownloadLatestTest()
}
[Fact]
- public void DriverDownloadTest()
+ public void DriverDownloadExactTest()
{
- new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);
+ new DriverManager().SetUpDriver(new ChromeConfig(), "115.0.5763.0");
+ Assert.NotEmpty(WebDriverFinder.FindFile(GetBinaryName()));
+ }
+ [Fact]
+ public void DriverDownloadMatchingBrowserTest()
+ {
+ new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);
Assert.NotEmpty(WebDriverFinder.FindFile(GetBinaryName()));
}
}
diff --git a/WebDriverManager.Tests/LegacyChromeConfigTests.cs b/WebDriverManager.Tests/LegacyChromeConfigTests.cs
new file mode 100644
index 0000000..19449f0
--- /dev/null
+++ b/WebDriverManager.Tests/LegacyChromeConfigTests.cs
@@ -0,0 +1,34 @@
+using System.Text.RegularExpressions;
+using WebDriverManager.DriverConfigs.Impl;
+using WebDriverManager.Helpers;
+using Xunit;
+
+namespace WebDriverManager.Tests
+{
+ public class LegacyChromeConfigTests : LegacyChromeConfig
+ {
+ [Fact]
+ public void VersionTest()
+ {
+ var version = GetLatestVersion();
+ var regex = new Regex(@"^\d+\.\d+.\d+.\d+$");
+ Assert.NotEmpty(version);
+ Assert.Matches(regex, version);
+ Assert.Equal("114.0.5735.90", version);
+ }
+
+ [Fact]
+ public void DriverDownloadLatestTest()
+ {
+ new DriverManager().SetUpDriver(new LegacyChromeConfig());
+ Assert.NotEmpty(WebDriverFinder.FindFile(GetBinaryName()));
+ }
+
+ [Fact]
+ public void DriverDownloadExactTest()
+ {
+ new DriverManager().SetUpDriver(new LegacyChromeConfig(), "106.0.5249.61");
+ Assert.NotEmpty(WebDriverFinder.FindFile(GetBinaryName()));
+ }
+ }
+}
diff --git a/WebDriverManager.Tests/LegacyEdgeConfigTests.cs b/WebDriverManager.Tests/LegacyEdgeConfigTests.cs
index 9cf1a04..6625ae7 100644
--- a/WebDriverManager.Tests/LegacyEdgeConfigTests.cs
+++ b/WebDriverManager.Tests/LegacyEdgeConfigTests.cs
@@ -14,6 +14,7 @@ public void VersionTest()
var regex = new Regex(@"^\d+\.\d+$");
Assert.NotEmpty(version);
Assert.Matches(regex, version);
+ Assert.Equal("6.17134", version);
}
[Fact]
diff --git a/WebDriverManager.Tests/PhantomConfigTests.cs b/WebDriverManager.Tests/PhantomConfigTests.cs
index a3aef9b..2e4c741 100644
--- a/WebDriverManager.Tests/PhantomConfigTests.cs
+++ b/WebDriverManager.Tests/PhantomConfigTests.cs
@@ -14,6 +14,7 @@ public void VersionTest()
var regex = new Regex(@"^\d+\.\d+\.\d+$");
Assert.NotEmpty(version);
Assert.Matches(regex, version);
+ Assert.Equal("2.1.1", version);
}
[Fact]
diff --git a/WebDriverManager.Tests/WebDriverManager.Tests.csproj b/WebDriverManager.Tests/WebDriverManager.Tests.csproj
index 5aad857..0883084 100644
--- a/WebDriverManager.Tests/WebDriverManager.Tests.csproj
+++ b/WebDriverManager.Tests/WebDriverManager.Tests.csproj
@@ -1,46 +1,46 @@
-
-
-
- false
- net472;netcoreapp3.1
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Always
-
-
-
- Always
-
-
-
- Always
-
-
-
-
-
-
- Always
-
-
-
-
- trx%3bLogFileName=Results$(TargetFramework).trx
-
-
+
+
+
+ false
+ net472;net7.0
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Always
+
+
+
+ Always
+
+
+
+ Always
+
+
+
+
+
+
+ Always
+
+
+
+
+ trx%3bLogFileName=Results$(TargetFramework).trx
+
+
diff --git a/WebDriverManager/DriverConfigs/Impl/BaseChromeConfig.cs b/WebDriverManager/DriverConfigs/Impl/BaseChromeConfig.cs
new file mode 100644
index 0000000..8e4655c
--- /dev/null
+++ b/WebDriverManager/DriverConfigs/Impl/BaseChromeConfig.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Runtime.InteropServices;
+using WebDriverManager.Helpers;
+using Architecture = WebDriverManager.Helpers.Architecture;
+
+namespace WebDriverManager.DriverConfigs.Impl
+{
+ public abstract class BaseChromeConfig : IDriverConfig
+ {
+ public abstract string GetLatestVersion();
+ public abstract string GetMatchingBrowserVersion();
+ protected abstract string GetUrl(Architecture architecture);
+
+ public virtual string GetName()
+ {
+ return "Chrome";
+ }
+
+ public virtual string GetUrl32()
+ {
+ return GetUrl(Architecture.X32);
+ }
+
+ public virtual string GetUrl64()
+ {
+ return GetUrl(Architecture.X64);
+ }
+
+ public virtual string GetBinaryName()
+ {
+ var isWindows = true;
+#if NETSTANDARD
+ isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+#endif
+ var suffix = isWindows ? ".exe" : string.Empty;
+ return $"chromedriver{suffix}";
+ }
+
+ protected 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",
+ "chrome", "--product-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
+ }
+ }
+}
diff --git a/WebDriverManager/DriverConfigs/Impl/ChromeConfig.cs b/WebDriverManager/DriverConfigs/Impl/ChromeConfig.cs
index 21abdc0..672d0dd 100644
--- a/WebDriverManager/DriverConfigs/Impl/ChromeConfig.cs
+++ b/WebDriverManager/DriverConfigs/Impl/ChromeConfig.cs
@@ -1,190 +1,23 @@
using System;
-using System.IO;
using System.Linq;
-using System.Net;
using System.Runtime.InteropServices;
using WebDriverManager.Clients;
using WebDriverManager.Helpers;
-using WebDriverManager.Models.Chrome;
using Architecture = WebDriverManager.Helpers.Architecture;
namespace WebDriverManager.DriverConfigs.Impl
{
- public class ChromeConfig : IDriverConfig
+ ///
+ /// Works with versions [115.0.5763.0; latest]
+ ///
+ public class ChromeConfig : BaseChromeConfig
{
- private const string BaseVersionPatternUrl = "https://chromedriver.storage.googleapis.com//";
- private const string ExactReleaseVersionPatternUrl = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_";
+ private const string BaseVersionPatternUrl =
+ "https://storage.googleapis.com/chrome-for-testing-public///chromedriver-.zip";
- ///
- /// The minimum version required to download chrome drivers from Chrome for Testing API's
- ///
- private static readonly Version MinChromeForTestingDriverVersion = new Version("115.0.5763.0");
-
- ///
- /// The minimum version of chrome driver required to reference download URLs via the "arm64" extension
- ///
- private static readonly Version MinArm64ExtensionVersion = new Version("106.0.5249.61");
-
- private ChromeVersionInfo _chromeVersionInfo;
- private string _chromeVersion;
-
- public virtual string GetName()
- {
- return "Chrome";
- }
-
- public virtual string GetUrl32()
- {
- return GetUrl(Architecture.X32);
- }
-
- public virtual string GetUrl64()
- {
- return GetUrl(Architecture.X64);
- }
-
- private string GetUrl(Architecture architecture)
- {
- // Handle newer versions of chrome driver only being available for download via the Chrome for Testing API's
- // whilst retaining backwards compatibility for older versions of chrome/chrome driver.
- if (_chromeVersionInfo != null)
- {
- return GetUrlFromChromeForTestingApi(architecture);
- }
-
- return GetUrlFromChromeStorage(architecture);
- }
-
- 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()
- {
- var chromeReleases = ChromeForTestingClient.GetLastKnownGoodVersions();
- var chromeStable = chromeReleases.Channels.Stable;
-
- _chromeVersionInfo = new ChromeVersionInfo
- {
- Downloads = chromeStable.Downloads
- };
-
- return chromeStable.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 chromeVersion = VersionHelper.GetVersionWithoutRevision(rawChromeBrowserVersion);
-
- // Handle downloading versions of the chrome webdriver less than what's supported by the Chrome for Testing known good versions API
- // See https://googlechromelabs.github.io/chrome-for-testing for more info
- var matchedVersion = new Version(rawChromeBrowserVersion);
- if (matchedVersion < MinChromeForTestingDriverVersion)
- {
- var url = ExactReleaseVersionPatternUrl.Replace("", chromeVersion);
- _chromeVersion = GetVersionFromChromeStorage(url);
- }
- else
- {
- _chromeVersion = GetVersionFromChromeForTestingApi(chromeVersion).Version;
- }
-
- return _chromeVersion;
- }
-
- ///
- /// Retrieves a chrome driver version string from https://chromedriver.storage.googleapis.com
- ///
- /// The request URL
- /// A chrome driver version string
- private static string GetVersionFromChromeStorage(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;
- }
- }
- }
- }
-
- ///
- /// Retrieves a download URL for a chrome driver from the https://chromedriver.storage.googleapis.com API's
- ///
- /// A chrome driver download URL
- private string GetUrlFromChromeStorage(Architecture architecture)
- {
-#if NETSTANDARD
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
- {
- // Handle older versions of chrome driver arm64 builds that are tagged with 64_m1 instead of arm64.
- // See: https://chromedriver.storage.googleapis.com/index.html?path=106.0.5249.21/
- var useM1Prefix = new Version(_chromeVersion) < MinArm64ExtensionVersion;
- var armArchitectureExtension = useM1Prefix
- ? "64_m1"
- : "_arm64";
-
- var architectureExtension = RuntimeInformation.ProcessArchitecture == System.Runtime.InteropServices.Architecture.Arm64
- ? armArchitectureExtension
- : "64";
-
- return $"{BaseVersionPatternUrl}chromedriver_mac{architectureExtension}.zip";
- }
-
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- {
- return $"{BaseVersionPatternUrl}chromedriver_linux64.zip";
- }
-#endif
- var driverName = architecture == Architecture.X32 ? "chromedriver_win32.zip" : "chromedriver_win64.zip";
- return $"{BaseVersionPatternUrl}{driverName}";
- }
-
- ///
- /// Retrieves a chrome driver version string from https://googlechromelabs.github.io/chrome-for-testing
- ///
- /// The desired version to download
- /// Chrome driver version info (version number, revision number, download URLs)
- private ChromeVersionInfo GetVersionFromChromeForTestingApi(string version)
- {
- var knownGoodVersions = ChromeForTestingClient.GetKnownGoodVersionsWithDownloads();
-
- // Pull latest patch version
- _chromeVersionInfo = knownGoodVersions.Versions.LastOrDefault(
- cV => cV.Version.Contains(version)
- );
-
- return _chromeVersionInfo;
- }
-
- ///
- /// Retrieves a chrome driver download URL from Chrome for Testing API's
- ///
- /// A chrome driver download URL
- private string GetUrlFromChromeForTestingApi(Architecture architecture)
+ protected override string GetUrl(Architecture architecture)
{
- string platform = architecture == Architecture.X32 ? "win32" : "win64";
-
+ string platform = architecture == Architecture.X64 ? "win64" : "win32";
#if NETSTANDARD
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
@@ -203,38 +36,28 @@ private string GetUrlFromChromeForTestingApi(Architecture architecture)
: "win32";
}
#endif
- var result = _chromeVersionInfo.Downloads.ChromeDriver
- .FirstOrDefault(driver => driver.Platform == platform);
-
- return result?.Url;
+ return BaseVersionPatternUrl.Replace("", platform);
}
- private string GetRawBrowserVersion()
+ public override string GetLatestVersion()
{
-#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",
- "chrome", "--product-version");
- }
+ var chromeReleases = ChromeForTestingClient.GetLastKnownGoodVersions();
+ return chromeReleases.Channels.Stable.Version;
+ }
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ public override string GetMatchingBrowserVersion()
+ {
+ var rawChromeBrowserVersion = GetRawBrowserVersion();
+ if (string.IsNullOrEmpty(rawChromeBrowserVersion))
{
- return RegistryHelper.GetInstalledBrowserVersionWin("chrome.exe");
+ throw new Exception("Not able to get chrome version or not installed");
}
- throw new PlatformNotSupportedException("Your operating system is not supported");
-#else
- return RegistryHelper.GetInstalledBrowserVersionWin("chrome.exe");
-#endif
+ var chromeVersion = VersionHelper.GetVersionWithoutRevision(rawChromeBrowserVersion);
+ var knownGoodVersions = ChromeForTestingClient.GetKnownGoodVersionsWithDownloads();
+ var chromeVersionInfo =
+ knownGoodVersions.Versions.LastOrDefault(info => info.Version.Contains(chromeVersion));
+ return chromeVersionInfo?.Version;
}
}
}
diff --git a/WebDriverManager/DriverConfigs/Impl/LegacyChromeConfig.cs b/WebDriverManager/DriverConfigs/Impl/LegacyChromeConfig.cs
new file mode 100644
index 0000000..61e1b46
--- /dev/null
+++ b/WebDriverManager/DriverConfigs/Impl/LegacyChromeConfig.cs
@@ -0,0 +1,77 @@
+using System;
+using System.IO;
+using System.Net;
+using System.Runtime.InteropServices;
+using WebDriverManager.Helpers;
+using Architecture = WebDriverManager.Helpers.Architecture;
+
+namespace WebDriverManager.DriverConfigs.Impl
+{
+ ///
+ /// Works with versions [106.0.5249.61; 114.0.5735.90]
+ ///
+ public class LegacyChromeConfig : BaseChromeConfig
+ {
+ private const string BaseVersionPatternUrl = "https://chromedriver.storage.googleapis.com//";
+ private const string LatestReleaseVersionUrl = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE";
+ private const string ExactReleaseVersionPatternUrl =
+ "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_";
+
+ protected override string GetUrl(Architecture architecture)
+ {
+#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 override string GetLatestVersion()
+ {
+ return GetLatestVersionFromUrl(LatestReleaseVersionUrl);
+ }
+
+ public override 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("", chromeBrowserVersion);
+ return GetLatestVersionFromUrl(url);
+ }
+
+ private static string GetLatestVersionFromUrl(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;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/WebDriverManager/DriverManager.cs b/WebDriverManager/DriverManager.cs
index cf8a86d..8c9abac 100644
--- a/WebDriverManager/DriverManager.cs
+++ b/WebDriverManager/DriverManager.cs
@@ -71,7 +71,7 @@ public string SetUpDriver(IDriverConfig config, string version = VersionResolveS
? ArchitectureHelper.GetArchitecture()
: architecture;
version = GetVersionToDownload(config, version);
- var url = architecture.Equals(Architecture.X32) ? config.GetUrl32() : config.GetUrl64();
+ var url = architecture == Architecture.X64 ? config.GetUrl64() : config.GetUrl32();
url = UrlHelper.BuildUrl(url, version);
var binaryPath = Path.Combine(_downloadDirectory, config.GetName(), version, architecture.ToString(), config.GetBinaryName());
return SetUpDriverImpl(url, binaryPath);
diff --git a/WebDriverManager/WebDriverManager.csproj b/WebDriverManager/WebDriverManager.csproj
index ee4c0f5..ae4efcc 100644
--- a/WebDriverManager/WebDriverManager.csproj
+++ b/WebDriverManager/WebDriverManager.csproj
@@ -4,7 +4,7 @@
false
net472;netstandard2.0;netstandard2.1
true
- 2.17.6
+ 2.17.7
WebDriverManager.Net
Automatic Selenium WebDriver binaries management for .Net
© 2016-2024, Aliaksandr Rasolka. All Rights Reserved.
@@ -14,7 +14,7 @@
git
README.md
Selenium WebDriver ChromeDriver EdgeDriver InternetExplorerDriver FirefoxDriver OperaDriver PhantomJsDriver
- Fix edge driver download url
+ Fix chrome exact version driver download
diff --git a/appveyor.yml b/appveyor.yml
index 34119b0..2867662 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -3,7 +3,7 @@ version: '{build}'
image: Visual Studio 2019
environment:
- LIBRARY_VERSION: '2.17.6'
+ LIBRARY_VERSION: '2.17.7'
SONAR_LOGIN:
secure: JNopXLZtkO5PD8yEj2+W1BZnbhq9oegXmTFgvVWQw67z5PtWwd+ngjv5O7xFetCZ