diff --git a/lib/CLAUDE.md b/lib/CLAUDE.md index 31efd5773..c355c8190 100644 --- a/lib/CLAUDE.md +++ b/lib/CLAUDE.md @@ -392,15 +392,20 @@ Test directory structure demonstrates comprehensive coverage: When running tests, always build first and then use the `--no-build` flag to avoid rebuilding during test execution. This provides faster and more reliable test runs: Always be explicit with the browser and protocol you want to test using ENV variables BROWSER=FIREFOX|CHROME and PROTOCOL=bidi|cdp +**IMPORTANT: Chrome should ALWAYS use CDP protocol. Firefox can use either CDP or BiDi.** + ```bash -# Build the test project first +# Build the test project first with Firefox and BiDi BROWSER=FIREFOX PROTOCOL=bidi dotnet build PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj # Then run tests with --no-build flag -BROWSER=CHROME PROTOCOL=bidi dotnet test PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj --filter "FullyQualifiedName~TestName" --no-build -- NUnit.TestOutputXml=TestResults +BROWSER=FIREFOX PROTOCOL=bidi dotnet test PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj --filter "FullyQualifiedName~TestName" --no-build -- NUnit.TestOutputXml=TestResults + +# Chrome should ALWAYS use CDP protocol +BROWSER=CHROME PROTOCOL=cdp dotnet build PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj && BROWSER=CHROME PROTOCOL=cdp dotnet test PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj --filter "FullyQualifiedName~TestName" --no-build -- NUnit.TestOutputXml=TestResults -# Can also chain them together -BROWSER=CHROME PROTOCOL=cdp dotnet build PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj && dotnet test PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj --filter "FullyQualifiedName~TestName" --no-build -- NUnit.TestOutputXml=TestResults +# Firefox should ALWAYS use bidi protocol +BROWSER=FIREFOX PROTOCOL=bidi dotnet build PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj && BROWSER=FIREFOX PROTOCOL=cdp dotnet test PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj --filter "FullyQualifiedName~TestName" --no-build -- NUnit.TestOutputXml=TestResults ``` You can switch between CDP and Bidi by changing the PuppeteerTestAttribute.IsCdp property. diff --git a/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json b/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json index 6ab799038..4c0cf0606 100644 --- a/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json +++ b/lib/PuppeteerSharp.Nunit/TestExpectations/TestExpectations.local.json @@ -1035,21 +1035,6 @@ "FAIL" ] }, - { - "comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one", - "testIdPattern": "[page.spec] *Page.select*", - "platforms": [ - "darwin", - "linux", - "win32" - ], - "parameters": [ - "webDriverBiDi" - ], - "expectations": [ - "FAIL" - ] - }, { "comment": "This is part of organizing the webdriver bidi implementation, We will remove it one by one", "testIdPattern": "[page.spec] *Page.setBypassCSP*", diff --git a/lib/PuppeteerSharp.TestServer/wwwroot/input/select.html b/lib/PuppeteerSharp.TestServer/wwwroot/input/select.html index 879a537a7..026d48e32 100644 --- a/lib/PuppeteerSharp.TestServer/wwwroot/input/select.html +++ b/lib/PuppeteerSharp.TestServer/wwwroot/input/select.html @@ -5,6 +5,7 @@ element.'); - - const options = Array.from(element.options); - element.value = undefined; - for (const option of options) { - option.selected = values.includes(option.value); - if (option.selected && !element.multiple) + { + if (values == null) + { + throw new ArgumentNullException(nameof(values)); + } + + foreach (var value in values) + { + if (value == null) + { + throw new ArgumentException($"Values must be strings. Found value \"null\" of type \"null\""); + } + } + + return BindIsolatedHandleAsync(handle => handle.EvaluateFunctionAsync( + @"(element, vals) => { + const values = new Set(vals); + if (!(element instanceof HTMLSelectElement)) { + throw new Error('Element is not a