From ed24da298db27056c51e39f5ea4e3aa686cb3a20 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Wed, 20 Aug 2025 12:49:15 +0300 Subject: [PATCH 1/3] Remove IEnumerable of command results --- .../BiDi/Browser/GetClientWindowsCommand.cs | 21 +------- .../BiDi/Browser/GetUserContextsCommand.cs | 19 +------- .../BrowsingContextScriptModule.cs | 2 +- .../BiDi/BrowsingContext/GetTreeCommand.cs | 18 +------ .../BrowsingContext/LocateNodesCommand.cs | 19 +------- .../webdriver/BiDi/Communication/Broker.cs | 6 --- .../GetClientWindowsResultConverter.cs | 43 ----------------- .../Enumerable/GetCookiesResultConverter.cs | 45 ----------------- .../Enumerable/GetRealmsResultConverter.cs | 43 ----------------- .../Enumerable/GetTreeResultConverter.cs | 43 ----------------- .../GetUserContextsResultConverter.cs | 43 ----------------- .../Enumerable/LocateNodesResultConverter.cs | 44 ----------------- .../webdriver/BiDi/Script/GetRealmsCommand.cs | 19 +------- .../BiDi/Storage/GetCookiesCommand.cs | 22 +-------- dotnet/test/common/BiDi/BiDiFixture.cs | 2 +- .../test/common/BiDi/Browser/BrowserTest.cs | 24 +++++----- .../BrowsingContext/BrowsingContextTest.cs | 24 +++++----- dotnet/test/common/BiDi/Input/SetFilesTest.cs | 4 +- .../BiDi/Script/CallFunctionParameterTest.cs | 10 ++-- .../BiDi/Script/EvaluateParametersTest.cs | 10 ++-- .../common/BiDi/Script/ScriptCommandsTest.cs | 28 +++++------ .../test/common/BiDi/Storage/StorageTest.cs | 48 +++++++++---------- 22 files changed, 82 insertions(+), 455 deletions(-) delete mode 100644 dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetClientWindowsResultConverter.cs delete mode 100644 dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetCookiesResultConverter.cs delete mode 100644 dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetRealmsResultConverter.cs delete mode 100644 dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetTreeResultConverter.cs delete mode 100644 dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetUserContextsResultConverter.cs delete mode 100644 dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/LocateNodesResultConverter.cs diff --git a/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs b/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs index 2d90714d20fec..08618af735406 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs @@ -18,7 +18,6 @@ // using OpenQA.Selenium.BiDi.Communication; -using System.Collections; using System.Collections.Generic; namespace OpenQA.Selenium.BiDi.Browser; @@ -28,22 +27,4 @@ internal sealed class GetClientWindowsCommand() public sealed class GetClientWindowsOptions : CommandOptions; -public sealed record GetClientWindowsResult : EmptyResult, IReadOnlyList -{ - internal GetClientWindowsResult(IReadOnlyList clientWindows) - { - ClientWindows = clientWindows; - } - - public IReadOnlyList ClientWindows { get; } - - public ClientWindowInfo this[int index] => ClientWindows[index]; - - public int Count => ClientWindows.Count; - - - - public IEnumerator GetEnumerator() => ClientWindows.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() => (ClientWindows as IEnumerable).GetEnumerator(); -} +public sealed record GetClientWindowsResult(IReadOnlyList ClientWindows) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs b/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs index 67d1648186f31..01c7749909acd 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs @@ -18,7 +18,6 @@ // using OpenQA.Selenium.BiDi.Communication; -using System.Collections; using System.Collections.Generic; namespace OpenQA.Selenium.BiDi.Browser; @@ -28,20 +27,4 @@ internal sealed class GetUserContextsCommand() public class GetUserContextsOptions : CommandOptions; -public sealed record GetUserContextsResult : EmptyResult, IReadOnlyList -{ - internal GetUserContextsResult(IReadOnlyList userContexts) - { - UserContexts = userContexts; - } - - public IReadOnlyList UserContexts { get; } - - public UserContextInfo this[int index] => UserContexts[index]; - - public int Count => UserContexts.Count; - - public IEnumerator GetEnumerator() => UserContexts.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() => (UserContexts as IEnumerable).GetEnumerator(); -} +public sealed record GetUserContextsResult(IReadOnlyList UserContexts) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs index 5d9d279fe5059..c8d905a4d468f 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs @@ -41,7 +41,7 @@ public async Task> GetRealmsAsync(GetRealmsOptions? opt options.Context = context; - return await scriptModule.GetRealmsAsync(options).ConfigureAwait(false); + return (await scriptModule.GetRealmsAsync(options).ConfigureAwait(false)).Realms; } public Task EvaluateAsync(string expression, bool awaitPromise, EvaluateOptions? options = null, ContextTargetOptions? targetOptions = null) diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs index fdc9d0c284d38..b2275283ba84b 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs @@ -47,20 +47,4 @@ public sealed record BrowsingContextGetTreeOptions public long? MaxDepth { get; set; } } -public sealed record GetTreeResult : EmptyResult, IReadOnlyList -{ - internal GetTreeResult(IReadOnlyList contexts) - { - Contexts = contexts; - } - - public IReadOnlyList Contexts { get; } - - public BrowsingContextInfo this[int index] => Contexts[index]; - - public int Count => Contexts.Count; - - public IEnumerator GetEnumerator() => Contexts.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() => (Contexts as IEnumerable).GetEnumerator(); -} +public sealed record GetTreeResult(IReadOnlyList Contexts) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs index 3f38ab986eeaf..3d18d994b84eb 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs @@ -18,7 +18,6 @@ // using OpenQA.Selenium.BiDi.Communication; -using System.Collections; using System.Collections.Generic; namespace OpenQA.Selenium.BiDi.BrowsingContext; @@ -37,20 +36,4 @@ public sealed class LocateNodesOptions : CommandOptions public IEnumerable? StartNodes { get; set; } } -public sealed record LocateNodesResult : EmptyResult, IReadOnlyList -{ - internal LocateNodesResult(IReadOnlyList nodes) - { - Nodes = nodes; - } - - public IReadOnlyList Nodes { get; } - - public Script.NodeRemoteValue this[int index] => Nodes[index]; - - public int Count => Nodes.Count; - - public IEnumerator GetEnumerator() => Nodes.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() => (Nodes as IEnumerable).GetEnumerator(); -} +public sealed record LocateNodesResult(IReadOnlyList Nodes) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Communication/Broker.cs b/dotnet/src/webdriver/BiDi/Communication/Broker.cs index f0c0f2c279f91..df003b9ae7e20 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Broker.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Broker.cs @@ -99,13 +99,7 @@ internal Broker(BiDi bidi, Uri url) // // Enumerable - new Json.Converters.Enumerable.GetCookiesResultConverter(), - new Json.Converters.Enumerable.LocateNodesResultConverter(), new Json.Converters.Enumerable.InputSourceActionsConverter(), - new Json.Converters.Enumerable.GetUserContextsResultConverter(), - new Json.Converters.Enumerable.GetClientWindowsResultConverter(), - new Json.Converters.Enumerable.GetRealmsResultConverter(), - new Json.Converters.Enumerable.GetTreeResultConverter(), } }; diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetClientWindowsResultConverter.cs b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetClientWindowsResultConverter.cs deleted file mode 100644 index a95315945e639..0000000000000 --- a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetClientWindowsResultConverter.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -using OpenQA.Selenium.BiDi.Communication.Json.Internal; -using OpenQA.Selenium.BiDi.Browser; -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; - -internal class GetClientWindowsResultConverter : JsonConverter -{ - public override GetClientWindowsResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - using var doc = JsonDocument.ParseValue(ref reader); - var clientWindows = doc.RootElement.GetProperty("clientWindows").Deserialize(options.GetTypeInfo>()); - - return new GetClientWindowsResult(clientWindows!); - } - - public override void Write(Utf8JsonWriter writer, GetClientWindowsResult value, JsonSerializerOptions options) - { - throw new NotImplementedException(); - } -} diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetCookiesResultConverter.cs b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetCookiesResultConverter.cs deleted file mode 100644 index 62db12fe20ef1..0000000000000 --- a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetCookiesResultConverter.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -using OpenQA.Selenium.BiDi.Communication.Json.Internal; -using OpenQA.Selenium.BiDi.Storage; -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; -using System.Text.Json.Serialization.Metadata; - -namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; - -internal class GetCookiesResultConverter : JsonConverter -{ - public override GetCookiesResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - using var doc = JsonDocument.ParseValue(ref reader); - var cookies = doc.RootElement.GetProperty("cookies").Deserialize(options.GetTypeInfo>()); - var partitionKey = doc.RootElement.GetProperty("partitionKey").Deserialize((JsonTypeInfo)options.GetTypeInfo(typeof(PartitionKey))); - - return new GetCookiesResult(cookies!, partitionKey!); - } - - public override void Write(Utf8JsonWriter writer, GetCookiesResult value, JsonSerializerOptions options) - { - throw new NotImplementedException(); - } -} diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetRealmsResultConverter.cs b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetRealmsResultConverter.cs deleted file mode 100644 index 86f773bbd0e47..0000000000000 --- a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetRealmsResultConverter.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -using OpenQA.Selenium.BiDi.Communication.Json.Internal; -using OpenQA.Selenium.BiDi.Script; -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; - -internal class GetRealmsResultConverter : JsonConverter -{ - public override GetRealmsResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - using var doc = JsonDocument.ParseValue(ref reader); - var realms = doc.RootElement.GetProperty("realms").Deserialize(options.GetTypeInfo>()); - - return new GetRealmsResult(realms!); - } - - public override void Write(Utf8JsonWriter writer, GetRealmsResult value, JsonSerializerOptions options) - { - throw new NotImplementedException(); - } -} diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetTreeResultConverter.cs b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetTreeResultConverter.cs deleted file mode 100644 index b928c9d8c5114..0000000000000 --- a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetTreeResultConverter.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -using OpenQA.Selenium.BiDi.BrowsingContext; -using OpenQA.Selenium.BiDi.Communication.Json.Internal; -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; - -internal class GetTreeResultConverter : JsonConverter -{ - public override GetTreeResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - using var doc = JsonDocument.ParseValue(ref reader); - var contexts = doc.RootElement.GetProperty("contexts").Deserialize(options.GetTypeInfo>()); - - return new GetTreeResult(contexts!); - } - - public override void Write(Utf8JsonWriter writer, GetTreeResult value, JsonSerializerOptions options) - { - throw new NotImplementedException(); - } -} diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetUserContextsResultConverter.cs b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetUserContextsResultConverter.cs deleted file mode 100644 index b5d471c4fe4c8..0000000000000 --- a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetUserContextsResultConverter.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -using OpenQA.Selenium.BiDi.Communication.Json.Internal; -using OpenQA.Selenium.BiDi.Browser; -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; - -internal class GetUserContextsResultConverter : JsonConverter -{ - public override GetUserContextsResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - using var doc = JsonDocument.ParseValue(ref reader); - var userContexts = doc.RootElement.GetProperty("userContexts").Deserialize(options.GetTypeInfo>()); - - return new GetUserContextsResult(userContexts!); - } - - public override void Write(Utf8JsonWriter writer, GetUserContextsResult value, JsonSerializerOptions options) - { - throw new NotImplementedException(); - } -} diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/LocateNodesResultConverter.cs b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/LocateNodesResultConverter.cs deleted file mode 100644 index d60e77b86b3d1..0000000000000 --- a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/LocateNodesResultConverter.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -using OpenQA.Selenium.BiDi.Communication.Json.Internal; -using OpenQA.Selenium.BiDi.BrowsingContext; -using OpenQA.Selenium.BiDi.Script; -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; - -internal class LocateNodesResultConverter : JsonConverter -{ - public override LocateNodesResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - using var doc = JsonDocument.ParseValue(ref reader); - var nodes = doc.RootElement.GetProperty("nodes").Deserialize(options.GetTypeInfo>()); - - return new LocateNodesResult(nodes!); - } - - public override void Write(Utf8JsonWriter writer, LocateNodesResult value, JsonSerializerOptions options) - { - throw new NotImplementedException(); - } -} diff --git a/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs b/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs index 94f23a1063c4c..d399b97527a9f 100644 --- a/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs @@ -18,7 +18,6 @@ // using OpenQA.Selenium.BiDi.Communication; -using System.Collections; using System.Collections.Generic; namespace OpenQA.Selenium.BiDi.Script; @@ -35,20 +34,4 @@ public sealed class GetRealmsOptions : CommandOptions public RealmType? Type { get; set; } } -public sealed record GetRealmsResult : EmptyResult, IReadOnlyList -{ - private readonly IReadOnlyList _realms; - - internal GetRealmsResult(IReadOnlyList realms) - { - _realms = realms; - } - - public RealmInfo this[int index] => _realms[index]; - - public int Count => _realms.Count; - - public IEnumerator GetEnumerator() => _realms.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() => (_realms as IEnumerable).GetEnumerator(); -} +public sealed record GetRealmsResult(IReadOnlyList Realms) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Storage/GetCookiesCommand.cs b/dotnet/src/webdriver/BiDi/Storage/GetCookiesCommand.cs index 781de8e09a4f9..e8337e784de86 100644 --- a/dotnet/src/webdriver/BiDi/Storage/GetCookiesCommand.cs +++ b/dotnet/src/webdriver/BiDi/Storage/GetCookiesCommand.cs @@ -19,7 +19,6 @@ using OpenQA.Selenium.BiDi.Communication; using System; -using System.Collections; using System.Collections.Generic; using System.Text.Json.Serialization; @@ -37,26 +36,7 @@ public sealed class GetCookiesOptions : CommandOptions public PartitionDescriptor? Partition { get; set; } } -public sealed record GetCookiesResult : EmptyResult, IReadOnlyList -{ - internal GetCookiesResult(IReadOnlyList cookies, PartitionKey partitionKey) - { - Cookies = cookies; - PartitionKey = partitionKey; - } - - public IReadOnlyList Cookies { get; } - - public PartitionKey PartitionKey { get; init; } - - public Network.Cookie this[int index] => Cookies[index]; - - public int Count => Cookies.Count; - - public IEnumerator GetEnumerator() => Cookies.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() => (Cookies as IEnumerable).GetEnumerator(); -} +public sealed record GetCookiesResult(IReadOnlyList Cookies, PartitionKey PartitionKey) : EmptyResult; public sealed record CookieFilter { diff --git a/dotnet/test/common/BiDi/BiDiFixture.cs b/dotnet/test/common/BiDi/BiDiFixture.cs index ba7574c653f67..88fe223a71d1c 100644 --- a/dotnet/test/common/BiDi/BiDiFixture.cs +++ b/dotnet/test/common/BiDi/BiDiFixture.cs @@ -46,7 +46,7 @@ public async Task BiDiSetUp() bidi = await driver.AsBiDiAsync(); - context = (await bidi.BrowsingContext.GetTreeAsync())[0].Context; + context = (await bidi.BrowsingContext.GetTreeAsync()).Contexts[0].Context; } [TearDown] diff --git a/dotnet/test/common/BiDi/Browser/BrowserTest.cs b/dotnet/test/common/BiDi/Browser/BrowserTest.cs index c00792c310268..eaa13ca8a24ee 100644 --- a/dotnet/test/common/BiDi/Browser/BrowserTest.cs +++ b/dotnet/test/common/BiDi/Browser/BrowserTest.cs @@ -38,12 +38,12 @@ public async Task CanGetUserContexts() var userContext1 = await bidi.Browser.CreateUserContextAsync(); var userContext2 = await bidi.Browser.CreateUserContextAsync(); - var userContexts = await bidi.Browser.GetUserContextsAsync(); + var userContextsResult = await bidi.Browser.GetUserContextsAsync(); - Assert.That(userContexts, Is.Not.Null); - Assert.That(userContexts, Has.Count.GreaterThanOrEqualTo(2)); - Assert.That(userContexts, Does.Contain(userContext1)); - Assert.That(userContexts, Does.Contain(userContext2)); + Assert.That(userContextsResult, Is.Not.Null); + Assert.That(userContextsResult.UserContexts, Has.Count.GreaterThanOrEqualTo(2)); + Assert.That(userContextsResult.UserContexts, Does.Contain(userContext1)); + Assert.That(userContextsResult.UserContexts, Does.Contain(userContext2)); } [Test] @@ -54,19 +54,19 @@ public async Task CanRemoveUserContext() await userContext2.UserContext.RemoveAsync(); - var userContexts = await bidi.Browser.GetUserContextsAsync(); + var userContextsResult = await bidi.Browser.GetUserContextsAsync(); - Assert.That(userContexts, Does.Contain(userContext1)); - Assert.That(userContexts, Does.Not.Contain(userContext2)); + Assert.That(userContextsResult.UserContexts, Does.Contain(userContext1)); + Assert.That(userContextsResult.UserContexts, Does.Not.Contain(userContext2)); } [Test] public async Task CanGetClientWindows() { - var clientWindows = await bidi.Browser.GetClientWindowsAsync(); + var clientWindowsResult = await bidi.Browser.GetClientWindowsAsync(); - Assert.That(clientWindows, Is.Not.Null); - Assert.That(clientWindows, Has.Count.GreaterThanOrEqualTo(1)); - Assert.That(clientWindows[0].ClientWindow, Is.Not.Null); + Assert.That(clientWindowsResult, Is.Not.Null); + Assert.That(clientWindowsResult.ClientWindows, Has.Count.GreaterThanOrEqualTo(1)); + Assert.That(clientWindowsResult.ClientWindows[0].ClientWindow, Is.Not.Null); } } diff --git a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs index ed10187f7e045..ee7a9ed75c5f1 100644 --- a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs +++ b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs @@ -105,10 +105,10 @@ public async Task CanGetTreeWithChild() var tree = await context.GetTreeAsync(); - Assert.That(tree, Has.Count.EqualTo(1)); - Assert.That(tree[0].Context, Is.EqualTo(context)); - Assert.That(tree[0].Children, Has.Count.EqualTo(1)); - Assert.That(tree[0].Children[0].Url, Does.Contain("formPage.html")); + Assert.That(tree.Contexts, Has.Count.EqualTo(1)); + Assert.That(tree.Contexts[0].Context, Is.EqualTo(context)); + Assert.That(tree.Contexts[0].Children, Has.Count.EqualTo(1)); + Assert.That(tree.Contexts[0].Children[0].Url, Does.Contain("formPage.html")); } [Test] @@ -118,9 +118,9 @@ public async Task CanGetTreeWithDepth() var tree = await context.GetTreeAsync(new() { MaxDepth = 0 }); - Assert.That(tree, Has.Count.EqualTo(1)); - Assert.That(tree[0].Context, Is.EqualTo(context)); - Assert.That(tree[0].Children, Is.Null); + Assert.That(tree.Contexts, Has.Count.EqualTo(1)); + Assert.That(tree.Contexts[0].Context, Is.EqualTo(context)); + Assert.That(tree.Contexts[0].Children, Is.Null); } [Test] @@ -131,7 +131,7 @@ public async Task CanGetTreeTopLevel() var tree = await bidi.BrowsingContext.GetTreeAsync(); - Assert.That(tree, Has.Count.GreaterThanOrEqualTo(2)); + Assert.That(tree.Contexts, Has.Count.GreaterThanOrEqualTo(2)); } [Test] @@ -143,7 +143,7 @@ public async Task CanCloseWindow() var tree = await bidi.BrowsingContext.GetTreeAsync(); - Assert.That(tree.Select(i => i.Context), Does.Not.Contain(window)); + Assert.That(tree.Contexts.Select(i => i.Context), Does.Not.Contain(window)); } [Test] @@ -155,7 +155,7 @@ public async Task CanCloseTab() var tree = await bidi.BrowsingContext.GetTreeAsync(); - Assert.That(tree.Select(i => i.Context), Does.Not.Contain(tab)); + Assert.That(tree.Contexts.Select(i => i.Context), Does.Not.Contain(tab)); } [Test] @@ -284,11 +284,11 @@ public async Task CanCaptureScreenshotOfElement() { await context.NavigateAsync(UrlBuilder.WhereIs("formPage.html"), new() { Wait = ReadinessState.Complete }); - var nodes = await context.LocateNodesAsync(new CssLocator("#checky")); + var nodesResult = await context.LocateNodesAsync(new CssLocator("#checky")); var screenshot = await context.CaptureScreenshotAsync(new() { - Clip = new ElementClipRectangle(nodes[0]) + Clip = new ElementClipRectangle(nodesResult.Nodes[0]) }); Assert.That(screenshot, Is.Not.Null); diff --git a/dotnet/test/common/BiDi/Input/SetFilesTest.cs b/dotnet/test/common/BiDi/Input/SetFilesTest.cs index d93c61e24d594..1f58ecbd408a4 100644 --- a/dotnet/test/common/BiDi/Input/SetFilesTest.cs +++ b/dotnet/test/common/BiDi/Input/SetFilesTest.cs @@ -45,9 +45,9 @@ public async Task CanSetFiles() { driver.Url = UrlBuilder.WhereIs("formPage.html"); - var nodes = await context.LocateNodesAsync(new CssLocator("[id='upload']")); + var nodesResult = await context.LocateNodesAsync(new CssLocator("[id='upload']")); - await context.Input.SetFilesAsync(nodes[0], [_tempFile]); + await context.Input.SetFilesAsync(nodesResult.Nodes[0], [_tempFile]); Assert.That(driver.FindElement(By.Id("upload")).GetAttribute("value"), Does.EndWith(Path.GetFileName(_tempFile))); } diff --git a/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs b/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs index d1752fa337584..a2a4c3e5b4da4 100644 --- a/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs +++ b/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs @@ -208,13 +208,13 @@ public async Task CanCallFunctionInARealm() { await bidi.BrowsingContext.CreateAsync(BrowsingContext.ContextType.Tab); - var realms = await bidi.Script.GetRealmsAsync(); + var realmsResult = await bidi.Script.GetRealmsAsync(); - await bidi.Script.CallFunctionAsync("() => { window.foo = 3; }", true, new RealmTarget(realms[0].Realm)); - await bidi.Script.CallFunctionAsync("() => { window.foo = 5; }", true, new RealmTarget(realms[1].Realm)); + await bidi.Script.CallFunctionAsync("() => { window.foo = 3; }", true, new RealmTarget(realmsResult.Realms[0].Realm)); + await bidi.Script.CallFunctionAsync("() => { window.foo = 5; }", true, new RealmTarget(realmsResult.Realms[1].Realm)); - var res1 = await bidi.Script.CallFunctionAsync("() => window.foo", true, new RealmTarget(realms[0].Realm)); - var res2 = await bidi.Script.CallFunctionAsync("() => window.foo", true, new RealmTarget(realms[1].Realm)); + var res1 = await bidi.Script.CallFunctionAsync("() => window.foo", true, new RealmTarget(realmsResult.Realms[0].Realm)); + var res2 = await bidi.Script.CallFunctionAsync("() => window.foo", true, new RealmTarget(realmsResult.Realms[1].Realm)); Assert.That(res1, Is.EqualTo(3)); Assert.That(res2, Is.EqualTo(5)); diff --git a/dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs b/dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs index 378fd4f949a7a..060f4a0e1a77a 100644 --- a/dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs +++ b/dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs @@ -114,13 +114,13 @@ public async Task CanEvaluateInARealm() { await bidi.BrowsingContext.CreateAsync(BrowsingContext.ContextType.Tab); - var realms = await bidi.Script.GetRealmsAsync(); + var realmsResult = await bidi.Script.GetRealmsAsync(); - await bidi.Script.EvaluateAsync("window.foo = 3", true, new RealmTarget(realms[0].Realm)); - await bidi.Script.EvaluateAsync("window.foo = 5", true, new RealmTarget(realms[1].Realm)); + await bidi.Script.EvaluateAsync("window.foo = 3", true, new RealmTarget(realmsResult.Realms[0].Realm)); + await bidi.Script.EvaluateAsync("window.foo = 5", true, new RealmTarget(realmsResult.Realms[1].Realm)); - var res1 = await bidi.Script.EvaluateAsync("window.foo", true, new RealmTarget(realms[0].Realm)); - var res2 = await bidi.Script.EvaluateAsync("window.foo", true, new RealmTarget(realms[1].Realm)); + var res1 = await bidi.Script.EvaluateAsync("window.foo", true, new RealmTarget(realmsResult.Realms[0].Realm)); + var res2 = await bidi.Script.EvaluateAsync("window.foo", true, new RealmTarget(realmsResult.Realms[1].Realm)); Assert.That(res1, Is.EqualTo(3)); Assert.That(res2, Is.EqualTo(5)); diff --git a/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs b/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs index ed285fc4b63a4..d68449bb750d4 100644 --- a/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs +++ b/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs @@ -30,16 +30,16 @@ public async Task CanGetAllRealms() { _ = await bidi.BrowsingContext.CreateAsync(BrowsingContext.ContextType.Window); - var realms = await bidi.Script.GetRealmsAsync(); + var realmsResult = await bidi.Script.GetRealmsAsync(); - Assert.That(realms, Is.Not.Null); - Assert.That(realms, Has.Count.EqualTo(2)); + Assert.That(realmsResult, Is.Not.Null); + Assert.That(realmsResult.Realms, Has.Count.EqualTo(2)); - Assert.That(realms[0], Is.AssignableFrom()); - Assert.That(realms[0].Realm, Is.Not.Null); + Assert.That(realmsResult.Realms[0], Is.AssignableFrom()); + Assert.That(realmsResult.Realms[0].Realm, Is.Not.Null); - Assert.That(realms[1], Is.AssignableFrom()); - Assert.That(realms[1].Realm, Is.Not.Null); + Assert.That(realmsResult.Realms[1], Is.AssignableFrom()); + Assert.That(realmsResult.Realms[1].Realm, Is.Not.Null); } [Test] @@ -47,16 +47,16 @@ public async Task CanGetAllRealmsByType() { _ = await bidi.BrowsingContext.CreateAsync(BrowsingContext.ContextType.Window); - var realms = await bidi.Script.GetRealmsAsync(new() { Type = RealmType.Window }); + var realmsResult = await bidi.Script.GetRealmsAsync(new() { Type = RealmType.Window }); - Assert.That(realms, Is.Not.Null); - Assert.That(realms, Has.Count.EqualTo(2)); + Assert.That(realmsResult, Is.Not.Null); + Assert.That(realmsResult.Realms, Has.Count.EqualTo(2)); - Assert.That(realms[0], Is.AssignableFrom()); - Assert.That(realms[0].Realm, Is.Not.Null); + Assert.That(realmsResult.Realms[0], Is.AssignableFrom()); + Assert.That(realmsResult.Realms[0].Realm, Is.Not.Null); - Assert.That(realms[1], Is.AssignableFrom()); - Assert.That(realms[1].Realm, Is.Not.Null); + Assert.That(realmsResult.Realms[1], Is.AssignableFrom()); + Assert.That(realmsResult.Realms[1].Realm, Is.Not.Null); } [Test] diff --git a/dotnet/test/common/BiDi/Storage/StorageTest.cs b/dotnet/test/common/BiDi/Storage/StorageTest.cs index 5857d599af513..3274cca813663 100644 --- a/dotnet/test/common/BiDi/Storage/StorageTest.cs +++ b/dotnet/test/common/BiDi/Storage/StorageTest.cs @@ -31,7 +31,7 @@ public async Task CanGetCookieByName() { driver.Url = UrlBuilder.WhereIs("animals"); - var cookies = await bidi.Storage.GetCookiesAsync(new() + var cookiesResult = await bidi.Storage.GetCookiesAsync(new() { Filter = new() { @@ -40,8 +40,8 @@ public async Task CanGetCookieByName() } }); - Assert.That(cookies, Is.Not.Null); - Assert.That(cookies, Is.Empty); + Assert.That(cookiesResult, Is.Not.Null); + Assert.That(cookiesResult.Cookies, Is.Empty); } [Test] @@ -49,9 +49,9 @@ public async Task CanGetCookieInDefaultUserContext() { driver.Url = UrlBuilder.WhereIs("animals"); - var userContexts = await bidi.Browser.GetUserContextsAsync(); + var userContextsResult = await bidi.Browser.GetUserContextsAsync(); - var cookies = await context.Storage.GetCookiesAsync(new() + var cookiesResult = await context.Storage.GetCookiesAsync(new() { Filter = new() { @@ -60,9 +60,9 @@ public async Task CanGetCookieInDefaultUserContext() } }); - Assert.That(cookies, Is.Not.Null); - Assert.That(cookies, Is.Empty); - Assert.That(cookies.PartitionKey.UserContext, Is.EqualTo(userContexts[0].UserContext)); + Assert.That(cookiesResult, Is.Not.Null); + Assert.That(cookiesResult.Cookies, Is.Empty); + Assert.That(cookiesResult.PartitionKey.UserContext, Is.EqualTo(userContextsResult.UserContexts[0].UserContext)); } [Test] @@ -92,12 +92,12 @@ await context.Storage.SetCookieAsync(new("fish", "cod", UrlBuilder.HostName) Expiry = expiry }); - var cookies = await context.Storage.GetCookiesAsync(); + var cookiesResult = await context.Storage.GetCookiesAsync(); - Assert.That(cookies, Is.Not.Null); - Assert.That(cookies, Has.Count.EqualTo(1)); + Assert.That(cookiesResult, Is.Not.Null); + Assert.That(cookiesResult.Cookies, Has.Count.EqualTo(1)); - var cookie = cookies[0]; + var cookie = cookiesResult.Cookies[0]; Assert.That(cookie.Name, Is.EqualTo("fish")); Assert.That((cookie.Value as StringBytesValue).Value, Is.EqualTo("cod")); @@ -118,12 +118,12 @@ public async Task CanGetAllCookies() driver.Manage().Cookies.AddCookie(new("key1", "value1")); driver.Manage().Cookies.AddCookie(new("key2", "value2")); - var cookies = await bidi.Storage.GetCookiesAsync(); + var cookiesResult = await bidi.Storage.GetCookiesAsync(); - Assert.That(cookies, Is.Not.Null); - Assert.That(cookies, Has.Count.EqualTo(2)); - Assert.That(cookies[0].Name, Is.EqualTo("key1")); - Assert.That(cookies[1].Name, Is.EqualTo("key2")); + Assert.That(cookiesResult, Is.Not.Null); + Assert.That(cookiesResult.Cookies, Has.Count.EqualTo(2)); + Assert.That(cookiesResult.Cookies[0].Name, Is.EqualTo("key1")); + Assert.That(cookiesResult.Cookies[1].Name, Is.EqualTo("key2")); } [Test] @@ -138,10 +138,10 @@ public async Task CanDeleteAllCookies() Assert.That(result, Is.Not.Null); - var cookies = await bidi.Storage.GetCookiesAsync(); + var cookiesResult = await bidi.Storage.GetCookiesAsync(); - Assert.That(cookies, Is.Not.Null); - Assert.That(cookies.Count, Is.EqualTo(0)); + Assert.That(cookiesResult, Is.Not.Null); + Assert.That(cookiesResult.Cookies.Count, Is.EqualTo(0)); } [Test] @@ -157,11 +157,11 @@ public async Task CanDeleteCookieWithName() Assert.That(result, Is.Not.Null); - var cookies = await bidi.Storage.GetCookiesAsync(); + var cookiesResult = await bidi.Storage.GetCookiesAsync(); - Assert.That(cookies, Is.Not.Null); - Assert.That(cookies, Has.Count.EqualTo(1)); - Assert.That(cookies[0].Name, Is.EqualTo("key2")); + Assert.That(cookiesResult, Is.Not.Null); + Assert.That(cookiesResult.Cookies, Has.Count.EqualTo(1)); + Assert.That(cookiesResult.Cookies[0].Name, Is.EqualTo("key2")); } [Test] From 44f8aa758ee04b17ce2a89754dd4321ef26f8b64 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 9 Oct 2025 23:12:57 -0400 Subject: [PATCH 2/3] Fix merge issues --- dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs | 1 - dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs | 1 - .../BiDi/BrowsingContext/BrowsingContextScriptModule.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs | 1 - .../src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs | 1 - dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs | 1 - dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs | 4 ++-- 7 files changed, 3 insertions(+), 8 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs b/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs index fbb00251ae548..08618af735406 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs @@ -19,7 +19,6 @@ using OpenQA.Selenium.BiDi.Communication; using System.Collections.Generic; -using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.Browser; diff --git a/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs b/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs index 503b4d28f8661..01c7749909acd 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs @@ -19,7 +19,6 @@ using OpenQA.Selenium.BiDi.Communication; using System.Collections.Generic; -using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.Browser; diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs index 20341d7c9b8dc..df91a3e893a2f 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs @@ -40,7 +40,7 @@ public async Task GetRealmsAsync(GetRealmsOptions? options = nu options.Context = context; - return (await scriptModule.GetRealmsAsync(options).ConfigureAwait(false)).Realms; + return await scriptModule.GetRealmsAsync(options).ConfigureAwait(false); } public Task EvaluateAsync(string expression, bool awaitPromise, EvaluateOptions? options = null, ContextTargetOptions? targetOptions = null) diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs index b2275283ba84b..c7ff247308e51 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs @@ -18,7 +18,6 @@ // using OpenQA.Selenium.BiDi.Communication; -using System.Collections; using System.Collections.Generic; namespace OpenQA.Selenium.BiDi.BrowsingContext; diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs index fe1507919f74f..3d18d994b84eb 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs @@ -19,7 +19,6 @@ using OpenQA.Selenium.BiDi.Communication; using System.Collections.Generic; -using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.BrowsingContext; diff --git a/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs b/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs index 4daf13a00cde0..d399b97527a9f 100644 --- a/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs @@ -19,7 +19,6 @@ using OpenQA.Selenium.BiDi.Communication; using System.Collections.Generic; -using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.Script; diff --git a/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs b/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs index 28352f6eb0841..e21b1748681c5 100644 --- a/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs +++ b/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs @@ -66,7 +66,7 @@ public async Task CanGetRealmInBrowsingContext() var realms = await tab.Context.Script.GetRealmsAsync(); - var tabRealm = realms[0] as WindowRealmInfo; + var tabRealm = realms.Realms[0] as WindowRealmInfo; Assert.That(tabRealm, Is.Not.Null); Assert.That(tabRealm.Context, Is.EqualTo(tab.Context)); @@ -79,7 +79,7 @@ public async Task CanGetRealmInBrowsingContextByType() var realms = await tab.Context.Script.GetRealmsAsync(new() { Type = RealmType.Window }); - var tabRealm = realms[0] as WindowRealmInfo; + var tabRealm = realms.Realms[0] as WindowRealmInfo; Assert.That(tabRealm, Is.Not.Null); Assert.That(tabRealm.Context, Is.EqualTo(tab.Context)); From b0295801f0178988674ac11515ec06671a917f2a Mon Sep 17 00:00:00 2001 From: Michael Render Date: Fri, 10 Oct 2025 00:32:59 -0400 Subject: [PATCH 3/3] Fix tests --- dotnet/test/common/BiDi/Browser/BrowserTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dotnet/test/common/BiDi/Browser/BrowserTest.cs b/dotnet/test/common/BiDi/Browser/BrowserTest.cs index 7a5502e98315c..39c4686b60124 100644 --- a/dotnet/test/common/BiDi/Browser/BrowserTest.cs +++ b/dotnet/test/common/BiDi/Browser/BrowserTest.cs @@ -43,8 +43,8 @@ public async Task CanGetUserContexts() Assert.That(userContextsResult, Is.Not.Null); Assert.That(userContextsResult.UserContexts, Has.Count.GreaterThanOrEqualTo(2)); - Assert.That(userContextsResult.UserContexts, Does.Contain(userContext1)); - Assert.That(userContextsResult.UserContexts, Does.Contain(userContext2)); + Assert.That(userContextsResult.UserContexts.Select(contextInfo => contextInfo.UserContext), Does.Contain(userContext1.UserContext)); + Assert.That(userContextsResult.UserContexts.Select(contextInfo => contextInfo.UserContext), Does.Contain(userContext2.UserContext)); } [Test] @@ -57,8 +57,8 @@ public async Task CanRemoveUserContext() var userContextsResult = await bidi.Browser.GetUserContextsAsync(); - Assert.That(userContextsResult.UserContexts, Does.Contain(userContext1)); - Assert.That(userContextsResult.UserContexts, Does.Not.Contain(userContext2)); + Assert.That(userContextsResult.UserContexts.Select(contextInfo => contextInfo.UserContext), Does.Contain(userContext1.UserContext)); + Assert.That(userContextsResult.UserContexts.Select(contextInfo => contextInfo.UserContext), Does.Not.Contain(userContext2.UserContext)); } [Test]