diff --git a/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs b/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs index ddb000303cad2..08618af735406 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs @@ -18,10 +18,7 @@ // using OpenQA.Selenium.BiDi.Communication; -using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; -using System.Collections; using System.Collections.Generic; -using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.Browser; @@ -30,21 +27,4 @@ internal sealed class GetClientWindowsCommand() public sealed class GetClientWindowsOptions : CommandOptions; -[JsonConverter(typeof(GetClientWindowsResultConverter))] -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 08b3b887ba032..01c7749909acd 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs @@ -18,10 +18,7 @@ // using OpenQA.Selenium.BiDi.Communication; -using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; -using System.Collections; using System.Collections.Generic; -using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.Browser; @@ -30,21 +27,4 @@ internal sealed class GetUserContextsCommand() public class GetUserContextsOptions : CommandOptions; -[JsonConverter(typeof(GetUserContextsResultConverter))] -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/GetTreeCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs index f3d989f40f94f..c7ff247308e51 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs @@ -18,10 +18,7 @@ // using OpenQA.Selenium.BiDi.Communication; -using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; -using System.Collections; using System.Collections.Generic; -using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.BrowsingContext; @@ -49,21 +46,4 @@ public sealed record BrowsingContextGetTreeOptions public long? MaxDepth { get; set; } } -[JsonConverter(typeof(GetTreeResultConverter))] -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 9ba8872e2f76e..3d18d994b84eb 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs @@ -18,10 +18,7 @@ // using OpenQA.Selenium.BiDi.Communication; -using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; -using System.Collections; using System.Collections.Generic; -using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.BrowsingContext; @@ -39,21 +36,4 @@ public sealed class LocateNodesOptions : CommandOptions public IEnumerable? StartNodes { get; set; } } -[JsonConverter(typeof(LocateNodesResultConverter))] -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/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 4adfd14c76acc..d399b97527a9f 100644 --- a/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs @@ -18,10 +18,7 @@ // using OpenQA.Selenium.BiDi.Communication; -using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; -using System.Collections; using System.Collections.Generic; -using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.Script; @@ -37,21 +34,4 @@ public sealed class GetRealmsOptions : CommandOptions public RealmType? Type { get; set; } } -[JsonConverter(typeof(GetRealmsResultConverter))] -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 8ff742f4a1e35..e8337e784de86 100644 --- a/dotnet/src/webdriver/BiDi/Storage/GetCookiesCommand.cs +++ b/dotnet/src/webdriver/BiDi/Storage/GetCookiesCommand.cs @@ -18,9 +18,7 @@ // using OpenQA.Selenium.BiDi.Communication; -using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; using System; -using System.Collections; using System.Collections.Generic; using System.Text.Json.Serialization; @@ -38,27 +36,7 @@ public sealed class GetCookiesOptions : CommandOptions public PartitionDescriptor? Partition { get; set; } } -[JsonConverter(typeof(GetCookiesResultConverter))] -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 09ac424869d1a..39c4686b60124 100644 --- a/dotnet/test/common/BiDi/Browser/BrowserTest.cs +++ b/dotnet/test/common/BiDi/Browser/BrowserTest.cs @@ -42,12 +42,9 @@ public async Task CanGetUserContexts() var userContextsResult = await bidi.Browser.GetUserContextsAsync(); Assert.That(userContextsResult, Is.Not.Null); - Assert.That(userContextsResult, Has.Count.GreaterThanOrEqualTo(2)); - - var userContexts = userContextsResult.Select(uc => uc.UserContext); - - Assert.That(userContexts, Does.Contain(userContext1.UserContext)); - Assert.That(userContexts, Does.Contain(userContext2.UserContext)); + Assert.That(userContextsResult.UserContexts, Has.Count.GreaterThanOrEqualTo(2)); + 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] @@ -58,20 +55,20 @@ public async Task CanRemoveUserContext() await userContext2.UserContext.RemoveAsync(); - var userContexts = (await bidi.Browser.GetUserContextsAsync()).Select(uc => uc.UserContext); + var userContextsResult = await bidi.Browser.GetUserContextsAsync(); - Assert.That(userContexts, Does.Contain(userContext1.UserContext)); - Assert.That(userContexts, Does.Not.Contain(userContext2.UserContext)); + 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] 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); } [Test] diff --git a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs index c0ae32fe0a118..a1a8cda5924b8 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 da751c8d23240..e21b1748681c5 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] @@ -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)); diff --git a/dotnet/test/common/BiDi/Storage/StorageTest.cs b/dotnet/test/common/BiDi/Storage/StorageTest.cs index 7d956e5d6424a..4fa13039787af 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]