diff --git a/Lombiq.Tests.UI/Lombiq.Tests.UI.csproj b/Lombiq.Tests.UI/Lombiq.Tests.UI.csproj index 2050ac965..7c6d783e2 100644 --- a/Lombiq.Tests.UI/Lombiq.Tests.UI.csproj +++ b/Lombiq.Tests.UI/Lombiq.Tests.UI.csproj @@ -64,10 +64,10 @@ - - - - + + + + @@ -86,9 +86,6 @@ - - diff --git a/Lombiq.Tests.UI/Models/BrowserLogEntry.cs b/Lombiq.Tests.UI/Models/BrowserLogEntry.cs index 687728463..4bebe92ab 100644 --- a/Lombiq.Tests.UI/Models/BrowserLogEntry.cs +++ b/Lombiq.Tests.UI/Models/BrowserLogEntry.cs @@ -15,7 +15,7 @@ public record BrowserLogEntry( DateTimeOffset Timestamp, StackTrace StackTrace) { - internal BrowserLogEntry(LogEntry entry) + internal BrowserLogEntry(EntryAddedEventArgs entry) : this(entry.Level, entry.Source, entry.Text, entry.Timestamp, entry.StackTrace) { } diff --git a/Lombiq.Tests.UI/Services/UITestContext.cs b/Lombiq.Tests.UI/Services/UITestContext.cs index 3ce6ef138..4fff515e6 100644 --- a/Lombiq.Tests.UI/Services/UITestContext.cs +++ b/Lombiq.Tests.UI/Services/UITestContext.cs @@ -6,6 +6,7 @@ using Lombiq.Tests.UI.SecurityScanning; using OpenQA.Selenium; using OpenQA.Selenium.BiDi; +using OpenQA.Selenium.BiDi.Log; using OpenQA.Selenium.BiDi.Network; using OrchardCore.Environment.Shell; using System; @@ -25,7 +26,7 @@ public sealed class UITestContext : IAsyncDisposable private readonly ConcurrentQueue _cumulativeBrowserLog = []; private readonly ConcurrentQueue _cumulativeResponseLog = []; - private BiDi _biDirectionalDriver; + private IBiDi _biDirectionalDriver; /// /// Gets the globally unique ID of this context. You can use this ID to refer to the current text execution in @@ -326,30 +327,34 @@ public static async Task CreateAsync( if (context.IsBrowserConfigured) { - context._biDirectionalDriver = await scope.Driver.AsBiDiAsync(); + context._biDirectionalDriver = await scope.Driver.AsBiDiAsync(cancellationToken: configuration.TestCancellationToken); // We intentionally don't pass the UITestContext to these callbacks: The callbacks are called asynchronously // by the browser (and Selenium), and e.g. the current URL can change between when a JS exception was thrown // and the callback is called. Thus, BrowserLogFilter could e.g. ignore log entries for a URL that actually // originated from a different URL and shouldn't be ignored. - await context._biDirectionalDriver.Log.OnEntryAddedAsync(entry => - { - var browserLogEntry = new Models.BrowserLogEntry(entry); - if (configuration.BrowserLogFilters.Values.All(filter => filter(browserLogEntry))) + await context._biDirectionalDriver.Log.EntryAdded.SubscribeAsync( + entry => { - context._cumulativeBrowserLog.Enqueue(browserLogEntry); - } - }); + var browserLogEntry = new Models.BrowserLogEntry(entry); + if (configuration.BrowserLogFilters.Values.All(filter => filter(browserLogEntry))) + { + context._cumulativeBrowserLog.Enqueue(browserLogEntry); + } + }, + configuration.TestCancellationToken); if (configuration.TestDumpConfiguration.CaptureResponseLog) { - await context._biDirectionalDriver.Network.OnResponseCompletedAsync(responseCompleted => - { - if (configuration.ResponseLogFilter(responseCompleted)) + await context._biDirectionalDriver.Network.ResponseCompleted.SubscribeAsync( + responseCompleted => { - context._cumulativeResponseLog.Enqueue(responseCompleted.Response); - } - }); + if (configuration.ResponseLogFilter(responseCompleted)) + { + context._cumulativeResponseLog.Enqueue(responseCompleted.Response); + } + }, + configuration.TestCancellationToken); } } diff --git a/renovate.json5 b/renovate.json5 index 76d8686f8..cbbe8f842 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -12,10 +12,6 @@ prBodyNotes: [ 'If Atata updated the Selenium version it uses, also see the [Selenium release notes](https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/CHANGELOG).', ], - // Selenium.WebDriver 4.39.0 causes JSON parsing issues (with 4.38.0 being safe), see: - // https://github.com/atata-framework/atata/discussions/862. Until this is resolved, Atata can't be updated. - // When this is fixed, remove both `enabled: false` and the Selenium.WebDriver section below. - enabled: false, }, { groupName: 'Browsers',