Skip to content

Commit d4802cf

Browse files
authored
Merge pull request #52 from csf-dev/issue-51
Resolves #51 - unused config properties no longer needlessly mandatory
2 parents b2b1902 + 16a8f27 commit d4802cf

306 files changed

Lines changed: 6401 additions & 846 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.appveyor.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/dotnetCi.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: .NET CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
11+
# Summary:
12+
#
13+
# * Installs and configures the environment
14+
# * Runs all .NET and JS tests
15+
# * In Debug configuration (.NET tests)
16+
# * WebDriver-based tests use a locally-running Chrome browser ONLY
17+
# * Packages test results as build artifacts
18+
# * Builds & packs the solution in Release configuration
19+
# * Uploads the Release config packages as build artifacts
20+
21+
build_test_and_pack:
22+
name: Build, test & package
23+
runs-on: ubuntu-24.04
24+
timeout-minutes: 30
25+
26+
env:
27+
VersionSuffix: ci.${{ github.run_number }}
28+
Configuration: Debug
29+
DotnetVersion: 8.0.x
30+
DISPLAY: :99
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
# Install build dependencies
39+
40+
- name: Add .NET global tools location to PATH
41+
run: echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
42+
- name: Install .NET
43+
uses: actions/setup-dotnet@v4
44+
with:
45+
dotnet-version: ${{ env.DotnetVersion }}
46+
- name: Install DocFX
47+
run: dotnet tool install --global docfx
48+
# See https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
49+
- name: Disable AppArmor restrictions so Chrome may run
50+
run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
51+
- name: Start an Xvfb display so Chrome may run
52+
run: Xvfb -ac $DISPLAY -screen 0 1280x1024x16 &
53+
54+
# Environment setup pre-build
55+
56+
- name: Restore .NET packages
57+
run: dotnet restore
58+
59+
# Build and test the solution
60+
61+
- name: Build the solution
62+
run: dotnet build -c ${{ env.Configuration }}
63+
- name: Run .NET tests
64+
id: dotnet_tests
65+
run: dotnet test
66+
continue-on-error: true
67+
68+
# Post-test tasks (artifacts, overall status)
69+
70+
- name: Gracefully stop Xvfb
71+
run: killall Xvfb
72+
continue-on-error: true
73+
- name: Upload .NET test results artifacts
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: NUnit test results
77+
path: Tests/*.Tests/**/TestResults.xml
78+
- name: Fail the build if any test failures
79+
if: steps.dotnet_tests.outcome == 'failure'
80+
run: |
81+
echo "Failing the build due to test failures"
82+
exit 1
83+
84+
# Build the apps in release mode and publish artifacts
85+
86+
- name: Clean the solution ahead of building in release config
87+
run: dotnet clean
88+
- name: Build, in release configuration
89+
run: dotnet pack -p:VersionSuffix=$VersionSuffix -o packages
90+
- name: Upload build result artifacts
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: Build results (NuGet)
94+
path: packages/*.nupkg
95+
- name: Build docs website
96+
run: docfx CSF.Extensions.WebDriver.Docs/docfx.json
97+
- name: Upload docs website artifact
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: Docs website
101+
path: docs/**/*

CSF.Extensions.WebDriver.Docs/docs/index.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ Do not forget that you may provide configuration from multiple sources; for exam
7171
7272
[`GetDefaultWebDriver()`]: xref:CSF.Extensions.WebDriver.IGetsWebDriver.GetDefaultWebDriver(System.Action{OpenQA.Selenium.DriverOptions})
7373

74+
### Configuration reference
75+
76+
The available configuration options/syntax is documented in the classes [`WebDriverCreationOptionsCollection`] and [`WebDriverCreationOptions`].
77+
78+
[`WebDriverCreationOptionsCollection`]: xref:CSF.Extensions.WebDriver.Factories.WebDriverCreationOptionsCollection
79+
[`WebDriverCreationOptions`]: xref:CSF.Extensions.WebDriver.Factories.WebDriverCreationOptions
80+
7481
## 3. Inject and use the services
7582

7683
Use dependency injection to inject an [`IGetsWebDriver`].
@@ -82,4 +89,3 @@ This service offers the same functionality except that the consumer is responsib
8289

8390
[`IGetsWebDriver`]: xref:CSF.Extensions.WebDriver.IGetsWebDriver
8491
[`ICreatesWebDriverFromOptions`]: xref:CSF.Extensions.WebDriver.Factories.ICreatesWebDriverFromOptions
85-
[`WebDriverCreationOptions`]: xref:CSF.Extensions.WebDriver.Factories.WebDriverCreationOptions

CSF.Extensions.WebDriver.Docs/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ This is broadly organised into three features:
1212
* A mechanism to ['mark WebDrivers up' with information about their quirks] which affect that browser/WebDriver/version combination
1313

1414
[Selenium WebDriver]: https://www.selenium.dev/documentation/webdriver/
15-
[universal WebDriver factory]: Docs/index.md
16-
[reliably identify WebDriver instances]: Docs/DriverIdentification.md
17-
['mark WebDrivers up' with information about their quirks]: Docs/Quirks.md
15+
[universal WebDriver factory]: docs/index.md
16+
[reliably identify WebDriver instances]: docs/DriverIdentification.md
17+
['mark WebDrivers up' with information about their quirks]: docs/Quirks.md

CSF.Extensions.WebDriver.Tests/CSF.Extensions.WebDriver.Tests.csproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,15 @@
2323
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
2424
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
2525
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
26-
<!-- Floating version should keep ChromeDriver up to date with the browser on the OS. See #47 for more info. -->
27-
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="*" Condition="'$(CI_LINUX)' != 'true'" />
28-
<!-- AppVeyor Linux builds use a fixed Chrome version, this driver version must match it; note that
29-
this might change over time (an will need to be manually kept in-sync) as they upgrade their CI images -->
30-
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="127.0.6533.9900" Condition="'$(CI_LINUX)' == 'true'" />
26+
<PackageReference Include="Selenium.WebDriver" Version="4.15.0" />
3127
</ItemGroup>
3228

3329
<ItemGroup>
3430
<ProjectReference Include="..\CSF.Extensions.WebDriver\CSF.Extensions.WebDriver.csproj" />
3531
</ItemGroup>
3632

3733
<ItemGroup>
38-
<Content Include="appsettings.WebDriverFactoryIntegrationTests.json">
34+
<Content Include="appsettings.*.json">
3935
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4036
</Content>
4137
</ItemGroup>

CSF.Extensions.WebDriver.Tests/Factories/SeleniumDriverAndOptionsScannerTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ public void GetKnownDriverAndOptionsTypesShouldContainAllOfTheExpectedDrivers(Se
3838
Warn.Unless(supportedDriverNames,
3939
Is.SupersetOf(expectedDriverNames),
4040
"The collection of supported drivers no longer contains all of expected drivers; breaking change in Selenium?");
41+
Assert.Pass("This isn't a true test, but if there has been a warning emitted then perhaps Selenium has introduced a change in built-in browser support.");
4142
}
4243
}

CSF.Extensions.WebDriver.Tests/Factories/WebDriverCreationConfigureOptionsTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ static async Task<WebDriverCreationOptionsCollection> GetOptionsAsync(IGetsWebDr
240240
{
241241
var options = new WebDriverCreationOptionsCollection();
242242
var config = await GetConfigurationAsync(json);
243-
var sut = new WebDriverCreationConfigureOptions(typeProvider, config, logger ?? Mock.Of<ILogger<WebDriverCreationConfigureOptions>>());
243+
var sut = new WebDriverCreationConfigureOptions(new WebDriverConfigurationItemParser(typeProvider, Mock.Of<ILogger<WebDriverConfigurationItemParser>>()),
244+
config,
245+
logger ?? Mock.Of<ILogger<WebDriverCreationConfigureOptions>>());
244246
sut.Configure(options);
245247
return options;
246248
}

CSF.Extensions.WebDriver.Tests/Factories/WebDriverFactoryIntegrationTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ public void GetDefaultWebDriverShouldReturnADriverProxyWithIdentification()
3232
Assert.That(() => driver.WebDriver.GetBrowserId(), Is.Not.Null);
3333
}
3434

35+
[Test]
36+
public void DriverTypeNorOptionsTypeShouldBeMandatoryIfACustomFactoryTypeIsSpecified()
37+
{
38+
var services = GetServiceProvider(o => o.SelectedConfiguration = "OmittedDriverAndOptionsType");
39+
var driverFactory = services.GetRequiredService<IGetsWebDriver>();
40+
using var driver = driverFactory.GetDefaultWebDriver();
41+
Assert.That(() => driver.WebDriver.GetBrowserId(), Is.Not.Null);
42+
}
43+
3544
IServiceProvider GetServiceProvider(Action<WebDriverCreationOptionsCollection>? configureOptions = null)
3645
{
3746
var services = new ServiceCollection();

CSF.Extensions.WebDriver.Tests/Factories/WebDriverTypesProviderTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ public class FakeWebDriver : IWebDriver
160160

161161
public class FakeOptions : DriverOptions
162162
{
163-
[Obsolete("Obsolete because base class is obsolete")]
164-
public override void AddAdditionalCapability(string capabilityName, object capabilityValue) => throw new NotImplementedException();
165-
166163
public override ICapabilities ToCapabilities() => throw new NotImplementedException();
167164
}
168165
}

CSF.Extensions.WebDriver.Tests/appsettings.WebDriverFactoryIntegrationTests.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"__Description__": "This configuration file is used by WebDriverFactoryIntegrationTests. It describes RemoteWebDriver configs which will raise a crash errors because of unsupported URL schemes. They are useful because they prove that Selenium's functionality is being exercised.",
2+
"__Description__": "This configuration file is used by WebDriverFactoryIntegrationTests. It describes a number of WebDriver config scenarios which will be tested.",
33
"WebDriverFactory": {
44
"DriverConfigurations": {
55
"DefaultFake": {
@@ -17,6 +17,9 @@
1717
"DriverType": "RemoteWebDriver",
1818
"OptionsType": "ChromeOptions",
1919
"GridUrl": "nonsense://127.0.0.1/no-http-request/should-be-made"
20+
},
21+
"OmittedDriverAndOptionsType": {
22+
"DriverFactoryType": "CSF.Extensions.WebDriver.Factories.WebDriverFactoryIntegrationTests+FakeWebDriverFactory, CSF.Extensions.WebDriver.Tests"
2023
}
2124
},
2225
"SelectedConfiguration": "DefaultInvalid"

0 commit comments

Comments
 (0)