Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
3.1.x
7.0.x
9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-restore --no-build

deploy:
needs: build
runs-on: ubuntu-latest
Expand Down
10 changes: 8 additions & 2 deletions WebDriverManager.Tests/ChromeConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
Expand Down
34 changes: 34 additions & 0 deletions WebDriverManager.Tests/LegacyChromeConfigTests.cs
Original file line number Diff line number Diff line change
@@ -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()));
}
}
}
1 change: 1 addition & 0 deletions WebDriverManager.Tests/LegacyEdgeConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions WebDriverManager.Tests/PhantomConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
92 changes: 46 additions & 46 deletions WebDriverManager.Tests/WebDriverManager.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"/>
<PackageReference Include="Selenium.WebDriver" Version="4.25.0" />
<PackageReference Include="xunit" Version="2.9.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WebDriverManager\WebDriverManager.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="Assets\file.txt" />
<Content Include="Assets\file.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Remove="Assets\removable.zip" />
<Content Include="Assets\removable.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Remove="Assets\unzipable.zip" />
<Content Include="Assets\unzipable.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<None Update="Assets\gzip.tar.gz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<PropertyGroup>
<VSTestLogger>trx%3bLogFileName=Results$(TargetFramework).trx</VSTestLogger>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<TargetFrameworks>net472;net7.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"/>
<PackageReference Include="Selenium.WebDriver" Version="4.25.0" />
<PackageReference Include="xunit" Version="2.9.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\WebDriverManager\WebDriverManager.csproj" />
</ItemGroup>

<ItemGroup>
<None Remove="Assets\file.txt" />
<Content Include="Assets\file.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Remove="Assets\removable.zip" />
<Content Include="Assets\removable.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Remove="Assets\unzipable.zip" />
<Content Include="Assets\unzipable.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<None Update="Assets\gzip.tar.gz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<PropertyGroup>
<VSTestLogger>trx%3bLogFileName=Results$(TargetFramework).trx</VSTestLogger>
</PropertyGroup>
</Project>
67 changes: 67 additions & 0 deletions WebDriverManager/DriverConfigs/Impl/BaseChromeConfig.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Loading
Loading