From d9769ffde545891102a1dec556143c0e8c3b56cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Sat, 28 Mar 2026 15:20:22 -0300 Subject: [PATCH] Fix page-fill.spec.ts headful test failures by aligning with upstream The page-fill tests failed in headful mode because several tests called Page.ClickAsync() on date/time/datetime-local inputs before filling them. In headful mode, clicking these inputs opens native date/time picker dialogs that block the subsequent fill operation, causing timeouts. Changes to match upstream Playwright tests: - Remove Page.ClickAsync("input") before fill on time, datetime-local, incorrect date, incorrect time, and incorrect datetime-local tests - Remove "range" from unsupported input types (now supported by server) - Add "invalid-type" to fillable input types list - Update incorrect date test value from "2020-13-02" to "2020-13-05" - Rename ShouldFillTimeInputAfterClicking to ShouldFillTimeInput - Use case-insensitive assertion for error messages - Remove expected-failure entry from TestExpectations.local.json Closes #125 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../TestExpectations.local.json | 6 ----- src/PlaywrightSharp.Tests/PageFillTests.cs | 22 +++++++++---------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json b/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json index 42a60d767..061247580 100644 --- a/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json +++ b/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json @@ -233,12 +233,6 @@ "parameters": ["headful"], "expectations": ["FAIL"] }, - { - "testIdPattern": "[page-fill.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["headful"], - "expectations": ["FAIL"] - }, { "testIdPattern": "[page-select-option.spec.ts] *", "platforms": ["darwin", "linux", "win32"], diff --git a/src/PlaywrightSharp.Tests/PageFillTests.cs b/src/PlaywrightSharp.Tests/PageFillTests.cs index 04b714ae3..512089d3f 100644 --- a/src/PlaywrightSharp.Tests/PageFillTests.cs +++ b/src/PlaywrightSharp.Tests/PageFillTests.cs @@ -31,11 +31,11 @@ public async Task ShouldFillInput() public async Task ShouldThrowOnUnsupportedInputs() { await Page.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html"); - foreach (string type in new[] { "button", "checkbox", "file", "image", "radio", "range", "reset", "submit" }) + foreach (string type in new[] { "button", "checkbox", "file", "image", "radio", "reset", "submit" }) { await Page.EvalOnSelectorAsync("input", "(input, type) => input.setAttribute('type', type)", type); var exception = Assert.ThrowsAsync(() => Page.FillAsync("input", string.Empty)); - Assert.That(exception.Message, Does.Contain($"input of type \"{type}\" cannot be filled")); + Assert.That(exception.Message, Does.Contain($"input of type \"{type}\" cannot be filled").IgnoreCase); } } @@ -44,7 +44,7 @@ public async Task ShouldThrowOnUnsupportedInputs() public async Task ShouldFillDifferentInputTypes() { await Page.GoToAsync(TestConstants.ServerUrl + "/input/textarea.html"); - foreach (string type in new[] { "password", "search", "tel", "text", "url" }) + foreach (string type in new[] { "password", "search", "tel", "text", "url", "invalid-type" }) { await Page.EvalOnSelectorAsync("input", "(input, type) => input.setAttribute('type', type)", type); await Page.FillAsync("input", "text " + type); @@ -67,17 +67,15 @@ public async Task ShouldFillDateInputAfterClicking() public async Task ShouldThrowOnIncorrectDate() { await Page.SetContentAsync(""); - await Page.ClickAsync("input"); - var exception = Assert.CatchAsync(() => Page.FillAsync("input", "2020-13-02")); + var exception = Assert.CatchAsync(() => Page.FillAsync("input", "2020-13-05")); Assert.That(exception.Message, Does.Contain("Malformed value")); } - [PlaywrightTest("page-fill.spec.ts", "should fill time input after clicking")] + [PlaywrightTest("page-fill.spec.ts", "should fill time input")] [Test, Timeout(TestConstants.DefaultTestTimeout)] - public async Task ShouldFillTimeInputAfterClicking() + public async Task ShouldFillTimeInput() { await Page.SetContentAsync(""); - await Page.ClickAsync("input"); await Page.FillAsync("input", "13:15"); Assert.That(await Page.EvalOnSelectorAsync("input", "input => input.value"), Is.EqualTo("13:15")); } @@ -87,7 +85,6 @@ public async Task ShouldFillTimeInputAfterClicking() public async Task ShouldThrowOnIncorrectTime() { await Page.SetContentAsync(""); - await Page.ClickAsync("input"); var exception = Assert.CatchAsync(() => Page.FillAsync("input", "25:05")); Assert.That(exception.Message, Does.Contain("Malformed value")); } @@ -97,7 +94,6 @@ public async Task ShouldThrowOnIncorrectTime() public async Task ShouldFillDatetimeLocalInput() { await Page.SetContentAsync(""); - await Page.ClickAsync("input"); await Page.FillAsync("input", "2020-03-02T05:15"); Assert.That(await Page.EvalOnSelectorAsync("input", "input => input.value"), Is.EqualTo("2020-03-02T05:15")); } @@ -107,7 +103,6 @@ public async Task ShouldFillDatetimeLocalInput() public async Task ShouldThrowOnIncorrectDateTimeLocal() { await Page.SetContentAsync(""); - await Page.ClickAsync("input"); var exception = Assert.CatchAsync(() => Page.FillAsync("input", "abc")); Assert.That(exception.Message, Does.Contain("Malformed value")); } @@ -237,7 +232,10 @@ public async Task ShouldFillFixedPositionInput() [Test, Timeout(TestConstants.DefaultTestTimeout)] public async Task ShouldBeAbleToFillWhenFocusIsInTheWrongFrame() { - await Page.SetContentAsync("
"); + await Page.SetContentAsync(@" +
+ + "); await Page.FocusAsync("iframe"); await Page.FillAsync("div", "some value"); Assert.That(await Page.EvalOnSelectorAsync("div", "d => d.textContent"), Is.EqualTo("some value"));