From a4a7d4d5974abfeccbcaab551ca2d947aa1a0aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Thu, 5 Nov 2026 12:34:29 -0300 Subject: [PATCH 1/5] Name the operation in a browser step's timeout message Port the fixture runtime's translated(call, ...): an engine error a browser step throws is mapped onto the runner taxonomy, and a timeout reads 'operation timed out in browser.goto '. Remove the ExpectedToFailAsync markers of frame-goto and wait-for-response that waited for it. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Ls2e1yaZFgZ3FEJkYScfkK --- src/E2E/Run/Browser.cs | 36 +++++++++++++++++-- .../FrameGoto/FrameGotoTests.cs | 16 +++------ .../PageWaitForResponseTests.cs | 14 +++----- .../RunnerEngineContractTests.cs | 2 +- 4 files changed, 44 insertions(+), 24 deletions(-) diff --git a/src/E2E/Run/Browser.cs b/src/E2E/Run/Browser.cs index 90ea00636..34ca64834 100644 --- a/src/E2E/Run/Browser.cs +++ b/src/E2E/Run/Browser.cs @@ -77,11 +77,43 @@ internal Browser(IEngineSession session, string platform, string? baseUrl, strin /// Runs one call that touches the app as a recorded step of the attempt, or as it is without a timeline. internal Task RunStepAsync(StepKind kind, string api, string label, Func body, bool verifies = false) => - Steps is null ? body() : Steps.RunAsync(kind, api, label, body, new StepRunOptions { Verifies = verifies }); + Steps is null ? Translated(Call(api, label), body) : Steps.RunAsync(kind, api, label, () => Translated(Call(api, label), body), new StepRunOptions { Verifies = verifies }); /// Runs one call that touches the app and returns a value as a recorded step of the attempt, or as it is without a timeline. internal Task RunStepAsync(StepKind kind, string api, string label, Func> body, bool verifies = false) => - Steps is null ? body() : Steps.RunAsync(kind, api, label, body, new StepRunOptions { Verifies = verifies }); + Steps is null ? Translated(Call(api, label), body) : Steps.RunAsync(kind, api, label, () => Translated(Call(api, label), body), new StepRunOptions { Verifies = verifies }); + + private static string Call(string api, string label) => label == "" ? api : api + " " + label; + + /// + /// Runs one operation and maps an it rejects with onto the runner taxonomy, as every other engine + /// surface is mapped (upstream's translated). names the operation and its label, so a timeout says + /// what it waited for. Anything else is rethrown as the call threw it. + /// + private static async Task Translated(string call, Func body) + { + try + { + await body().ConfigureAwait(false); + } + catch (EngineException cause) + { + throw ErrorSerializer.TranslateEngineError(cause, " in " + call); + } + } + + /// + private static async Task Translated(string call, Func> body) + { + try + { + return await body().ConfigureAwait(false); + } + catch (EngineException cause) + { + throw ErrorSerializer.TranslateEngineError(cause, " in " + call); + } + } /// Tells the attempt that an assertion failed on the app. Nothing outside a session listens. internal Action Failed { get; set; } = static () => { }; diff --git a/tests/E2E.NUnit.Tests/FrameGoto/FrameGotoTests.cs b/tests/E2E.NUnit.Tests/FrameGoto/FrameGotoTests.cs index bf3d7df0f..33aa1264c 100644 --- a/tests/E2E.NUnit.Tests/FrameGoto/FrameGotoTests.cs +++ b/tests/E2E.NUnit.Tests/FrameGoto/FrameGotoTests.cs @@ -15,20 +15,12 @@ namespace E2E.NUnit.Tests.FrameGoto; /// public sealed class FrameGotoTests : PlaywrightTest { - // Known difference, hardkoded/e2e-dotnet#1068: the timeout message has no `timed out in browser.goto` label. [Test] public async Task Should_continue_after_client_redirect() { - await ExpectedToFailAsync("child-redirect.html: Timeout", async () => - { - await Browser.RouteAsync("**/frames/script.js", route => route.ContinueAsync(new RouteContinueOverrides { Url = $"{PREFIX}/never" })); - var url = $"{PREFIX}/frames/child-redirect.html"; - var error = await Record(() => Browser.GotoAsync(url, new GotoOptions { Timeout = TimeSpan.FromSeconds(5), WaitUntil = GotoWaitUntil.NetworkIdle })); - - if (error is null || !error.Message.Contains("timed out in browser.goto", StringComparison.Ordinal)) - { - throw new InvalidOperationException("Expected a message with 'timed out in browser.goto', but was: " + (error?.Message ?? "no error")); - } - }); + await Browser.RouteAsync("**/frames/script.js", route => route.ContinueAsync(new RouteContinueOverrides { Url = $"{PREFIX}/never" })); + var url = $"{PREFIX}/frames/child-redirect.html"; + var error = await Record(() => Browser.GotoAsync(url, new GotoOptions { Timeout = TimeSpan.FromSeconds(5), WaitUntil = GotoWaitUntil.NetworkIdle })); + Contain("timed out in browser.goto", error?.Message ?? "no error"); } } diff --git a/tests/E2E.NUnit.Tests/WaitForResponse/PageWaitForResponseTests.cs b/tests/E2E.NUnit.Tests/WaitForResponse/PageWaitForResponseTests.cs index 19b8c2b10..cd2cb19b7 100644 --- a/tests/E2E.NUnit.Tests/WaitForResponse/PageWaitForResponseTests.cs +++ b/tests/E2E.NUnit.Tests/WaitForResponse/PageWaitForResponseTests.cs @@ -38,15 +38,11 @@ await Browser.EvaluateAsync(""" [Test] public async Task Should_log_the_url() { - // Known difference (hardkoded/e2e-dotnet#1068): the timeout message does not name the pattern yet. - await ExpectedToFailAsync("Timeout 1000ms exceeded", async () => - { - await Browser.GotoAsync(EmptyPage); - var error1 = await Assert.CatchAsync(() => Browser.WaitForResponseAsync("foo.css", TimeSpan.FromMilliseconds(1000))); - Contain("\"foo.css\"", error1!.Message); - var error2 = await Assert.CatchAsync(() => Browser.WaitForResponseAsync(new Regex("foo.css", RegexOptions.IgnoreCase), TimeSpan.FromMilliseconds(1000))); - Contain("/foo.css/i", error2!.Message); - }); + await Browser.GotoAsync(EmptyPage); + var error1 = await Assert.CatchAsync(() => Browser.WaitForResponseAsync("foo.css", TimeSpan.FromMilliseconds(1000))); + Contain("\"foo.css\"", error1!.Message); + var error2 = await Assert.CatchAsync(() => Browser.WaitForResponseAsync(new Regex("foo.css", RegexOptions.IgnoreCase), TimeSpan.FromMilliseconds(1000))); + Contain("/foo.css/i", error2!.Message); } [Test] diff --git a/tests/E2E.Tests/EngineContract/RunnerEngineContractTests.cs b/tests/E2E.Tests/EngineContract/RunnerEngineContractTests.cs index e599ee792..fa45873fd 100644 --- a/tests/E2E.Tests/EngineContract/RunnerEngineContractTests.cs +++ b/tests/E2E.Tests/EngineContract/RunnerEngineContractTests.cs @@ -78,7 +78,7 @@ public async Task Reaching_a_fixture_the_engine_does_not_contribute_is_a_configu TestTitle = "needs browser", }); await session.App.OpenAsync("/settings/billing"); - var error = await Assert.ThrowsAsync(() => session.Browser.GotoAsync("/somewhere")); + var error = await Assert.ThrowsAsync(() => session.Browser.GotoAsync("/somewhere")); Assert.Equal("UNSUPPORTED_CAPABILITY", error.Code); Assert.Contains("browser.goto needs a browser engine", error.Message, StringComparison.Ordinal); } From a9e2bbbb3972d1cfa7b32d42b619bfd3a27a6ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Thu, 5 Nov 2026 12:35:08 -0300 Subject: [PATCH 2/5] Note the browser step translation in COMPATIBILITY Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Ls2e1yaZFgZ3FEJkYScfkK --- COMPATIBILITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index 184e90984..a963a153c 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -122,7 +122,7 @@ Names are C# versions of the JavaScript API: `agent.act` is `ActAsync`, `screen. ## Error codes that differ -A locator reports an engine failure as upstream's `translateLocatorError` (`LocatorEngine.TranslateLocatorError`, over `ErrorSerializer.TranslateEngineError`, upstream's `translateEngineError`, `internal/errors.ts`) does, with the engine error as `InnerException` and the locator's description added to the message (#846): `NOT_ACTIONABLE` and `ACTION_MAY_HAVE_COMMITTED` are `ACTION_FAILED`, `OPERATION_TIMEOUT` is `ACTION_FAILED` (`operation timed out: `), `NODE_STALE` and `FRAME_NOT_FOUND` are `LOCATOR_NOT_FOUND`, `FRAME_AMBIGUOUS` is `LOCATOR_AMBIGUOUS`, and `INVALID_STATE` is `APP_NOT_OPEN`. `CANCELLED` is an `EngineException` of that code (`operation cancelled`), `UNSUPPORTED_CAPABILITY` is a `ConfigurationException` (category `configuration`), and `ENGINE_FAILURE`, any other engine code, and an error that is no e2e error are an `EngineException` `ENGINE_FAILURE` (category `infrastructure`), each with the original error as `InnerException`, as upstream's `translateEngineError` wraps them (#885). Differences: an `OperationCanceledException` is returned as it is, so a caller's cancel stays a cancel. The port applies the translation to the locator's resolve (including the resolve over an observation) and to its actions; it has no read by reference to translate. `LocatorEngine` (`Locator/LocatorEngine.cs`, upstream's `locator/engine.ts`, #994) owns the resolve, the retries, the deadlines, the engine events, and the operation context a call carries (`OperationContext.Test`); `Screen` and `Locator` pass it their query. Differences: its session is the set of calls in `LocatorEngineOptions` (.NET-only: the attempt reads the screen through its scope), a locate answers the nodes themselves so `read`, `readNow`, `readAllNow`, and `tryRead` read a resolve and have no `session.read` to go stale, `fillSecret` and `pressSequentially` are not engine methods (a secret fill and a typed text are engine actions), and `DeadlineFor` is upstream's `deadline` (`Deadline` is the type's name). `LocatorEngine/` ports the `read retry`, `resolve retry`, `perform`, `readAllNow`, `reads that do not wait`, `translateLocatorError`, `visible queries`, `isNodeVisible`, and `locator failure candidate counts` (`LocatorFailureCandidateCountsTests`) describes; not ported: the its that need `session.read` to go stale (read retry 1 to 3, read contract, readAllNow stale and failure, readNow stale between resolve and read), `secret fill` (no engine `fillSecret`), `AttemptBudget.capped` (no `AttemptBudget`), and the cross-realm describe (no second module registry in .NET). A filtered locator that matches nothing or too many lists the candidates each filter step left (tester-army/e2e#1416, `79e2e13d3365`): `LocatorExpression.FilterSpine()` is `filterSpine` (`locator/expression.ts`), and `LocatorEngine.CandidateCountsAsync` is `candidateCounts`, read by `NotFoundAsync` (`notFound` in `resolveCounted`) and `AmbiguousAsync` (`singleOf`, which replaces `assertSingle`), one immediate resolve per prefix of the chain under one 500 ms budget (`StepCountBudget`, `STEP_COUNT_BUDGET_MS`; `Deadline.Min` is `Deadline.min`). A walk that cannot finish says `walk stopped after N of M steps`, a read that fails drops the list, and a cancel surfaces as cancellation. Differences: the port's failure messages are its own (` matched 0 nodes.`), so the list follows on a new line (`candidates left after each filter step, counted after the failure:`) where upstream continues after `; `. The five `filterSpine` its are in `Expression/LocatorExpressionsTests`. An action whose engine call finds a retryable stale node resolves the locator again and repeats the action while its deadline remains, as upstream's `performUntil` does; an action that may have committed is never repeated. An action whose deadline passed before it was sent is not sent: it fails with `ACTION_FAILED` (`operation timed out before the tap was sent: `), as upstream's `lateAction` (#869). Tests: `LocatorEngine/TranslateLocatorErrorMappingTableTests` (the `translateLocatorError mapping table` describe; the seven rows with the port's codes are `Partial_`) and the perform `it`s of `LocatorEngine/LocatorEnginePerformContractTests`. All six perform `it`s are ported; `marks every action it performs with the test origin` runs on the `LocatorEngine` itself (`ScriptedLocatorEngine`, upstream's `makeEngine`), and a .NET-only test checks that `E2ESession` wires that origin to the engine a test's step reaches (`OriginRecordingEngine`). +A locator reports an engine failure as upstream's `translateLocatorError` (`LocatorEngine.TranslateLocatorError`, over `ErrorSerializer.TranslateEngineError`, upstream's `translateEngineError`, `internal/errors.ts`) does, with the engine error as `InnerException` and the locator's description added to the message (#846): `NOT_ACTIONABLE` and `ACTION_MAY_HAVE_COMMITTED` are `ACTION_FAILED`, `OPERATION_TIMEOUT` is `ACTION_FAILED` (`operation timed out: `), `NODE_STALE` and `FRAME_NOT_FOUND` are `LOCATOR_NOT_FOUND`, `FRAME_AMBIGUOUS` is `LOCATOR_AMBIGUOUS`, and `INVALID_STATE` is `APP_NOT_OPEN`. `CANCELLED` is an `EngineException` of that code (`operation cancelled`), `UNSUPPORTED_CAPABILITY` is a `ConfigurationException` (category `configuration`), and `ENGINE_FAILURE`, any other engine code, and an error that is no e2e error are an `EngineException` `ENGINE_FAILURE` (category `infrastructure`), each with the original error as `InnerException`, as upstream's `translateEngineError` wraps them (#885). A browser step maps the engine error it throws the same way (`Browser.Translated`, upstream's `translated` in `run/fixture-recording.ts`), with ` in