From 62264e3ad6411c05e19715ab774f5fdd54181a1c Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 17:37:52 +0300 Subject: [PATCH 01/12] Emulation placeholder --- dotnet/src/webdriver/BiDi/BiDi.cs | 14 ++++++++++++++ .../webdriver/BiDi/Emulation/EmulationModule.cs | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs diff --git a/dotnet/src/webdriver/BiDi/BiDi.cs b/dotnet/src/webdriver/BiDi/BiDi.cs index 0ffc7b8fdeaf2..3edb8edac2401 100644 --- a/dotnet/src/webdriver/BiDi/BiDi.cs +++ b/dotnet/src/webdriver/BiDi/BiDi.cs @@ -37,6 +37,7 @@ public sealed class BiDi : IAsyncDisposable private Log.LogModule? _logModule; private Storage.StorageModule? _storageModule; private WebExtension.WebExtensionModule? _webExtensionModule; + private Emulation.EmulationModule? _emulationModule; private readonly object _moduleLock = new(); @@ -164,6 +165,19 @@ public WebExtension.WebExtensionModule WebExtension } } + public Emulation.EmulationModule Emulation + { + get + { + if (_emulationModule is not null) return _emulationModule; + lock (_moduleLock) + { + _emulationModule ??= new Emulation.EmulationModule(_broker); + } + return _emulationModule; + } + } + public Task StatusAsync() { return SessionModule.StatusAsync(); diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs new file mode 100644 index 0000000000000..0add496df0791 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -0,0 +1,8 @@ +using OpenQA.Selenium.BiDi.Communication; + +namespace OpenQA.Selenium.BiDi.Emulation; + +public sealed class EmulationModule(Broker broker) : Module(broker) +{ + +} From 1c957e642b8827cd9d4cce66e419739c289020dc Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 17:56:02 +0300 Subject: [PATCH 02/12] SetTimezone --- .../Json/BiDiJsonSerializerContext.cs | 2 ++ .../BiDi/Emulation/EmulationModule.cs | 25 +++++++++++++ .../Emulation/SetTimezoneOverrideCommand.cs | 35 +++++++++++++++++++ .../common/BiDi/Emulation/EmulationTest.cs | 32 +++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs create mode 100644 dotnet/test/common/BiDi/Emulation/EmulationTest.cs diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index b2510f252dbc2..f0ecedfae41a3 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -173,4 +173,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(WebExtension.InstallResult))] [JsonSerializable(typeof(WebExtension.UninstallCommand))] +[JsonSerializable(typeof(Emulation.SetTimezoneOverrideCommand))] + internal partial class BiDiJsonSerializerContext : JsonSerializerContext; diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index 0add496df0791..690623869b395 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -1,8 +1,33 @@ +// +// 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 System.Threading.Tasks; using OpenQA.Selenium.BiDi.Communication; namespace OpenQA.Selenium.BiDi.Emulation; public sealed class EmulationModule(Broker broker) : Module(broker) { + public async Task SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null) + { + var @params = new SetTimezoneOverrideParameters(timezone, options?.Contexts, options?.UserContexts); + return await Broker.ExecuteCommandAsync(new SetTimezoneOverrideCommand(@params), options).ConfigureAwait(false); + } } diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs new file mode 100644 index 0000000000000..90f3d3172045e --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs @@ -0,0 +1,35 @@ +// +// 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 System.Collections.Generic; +using OpenQA.Selenium.BiDi.Communication; + +namespace OpenQA.Selenium.BiDi.Emulation; + +internal sealed class SetTimezoneOverrideCommand(SetTimezoneOverrideParameters @params) + : Command(@params, "emulation.setTimezoneOverride"); + +internal sealed record SetTimezoneOverrideParameters(string? Timezone, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; + +public sealed class SetTimezoneOverrideOptions : CommandOptions +{ + public IEnumerable? Contexts { get; set; } + + public IEnumerable? UserContexts { get; set; } +} diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs new file mode 100644 index 0000000000000..495e84ad49d4f --- /dev/null +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -0,0 +1,32 @@ +// +// 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 NUnit.Framework; + +namespace OpenQA.Selenium.BiDi.Emulation; + +class EmulationTest : BiDiTestFixture +{ + [Test] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet")] + public void CanSetTimezoneOverride() + { + Assert.That(async () => await bidi.Emulation.SetTimezoneOverrideAsync("UTC", new () { Contexts = [context] }), Throws.Nothing); + } +} From c97e8fcdf8e8a2f7240c80ae99028968b579af4e Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 18:02:18 +0300 Subject: [PATCH 03/12] SetUserAgent --- .../Json/BiDiJsonSerializerContext.cs | 2 +- .../BiDi/Emulation/EmulationModule.cs | 7 ++++ .../Emulation/SetUserAgentOverrideCommand.cs | 35 +++++++++++++++++++ .../common/BiDi/Emulation/EmulationTest.cs | 7 +++- 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index f0ecedfae41a3..db0fd712c3171 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -172,7 +172,7 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(WebExtension.InstallCommand))] [JsonSerializable(typeof(WebExtension.InstallResult))] [JsonSerializable(typeof(WebExtension.UninstallCommand))] - [JsonSerializable(typeof(Emulation.SetTimezoneOverrideCommand))] +[JsonSerializable(typeof(Emulation.SetUserAgentOverrideCommand))] internal partial class BiDiJsonSerializerContext : JsonSerializerContext; diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index 690623869b395..ddc6266e00174 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -30,4 +30,11 @@ public async Task SetTimezoneOverrideAsync(string? timezone, SetTim return await Broker.ExecuteCommandAsync(new SetTimezoneOverrideCommand(@params), options).ConfigureAwait(false); } + + public async Task SetUserAgentOverrideAsync(string? userAgent, SetUserAgentOverrideOptions? options = null) + { + var @params = new SetUserAgentOverrideParameters(userAgent, options?.Contexts, options?.UserContexts); + + return await Broker.ExecuteCommandAsync(new SetUserAgentOverrideCommand(@params), options).ConfigureAwait(false); + } } diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs new file mode 100644 index 0000000000000..b8f90367fd89e --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs @@ -0,0 +1,35 @@ +// +// 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 System.Collections.Generic; +using OpenQA.Selenium.BiDi.Communication; + +namespace OpenQA.Selenium.BiDi.Emulation; + +internal sealed class SetUserAgentOverrideCommand(SetUserAgentOverrideParameters @params) + : Command(@params, "emulation.setUserAgentOverride"); + +internal sealed record SetUserAgentOverrideParameters(string? UserAgent, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; + +public sealed class SetUserAgentOverrideOptions : CommandOptions +{ + public IEnumerable? Contexts { get; set; } + + public IEnumerable? UserContexts { get; set; } +} diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs index 495e84ad49d4f..30804a64f3393 100644 --- a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -24,9 +24,14 @@ namespace OpenQA.Selenium.BiDi.Emulation; class EmulationTest : BiDiTestFixture { [Test] - [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet")] public void CanSetTimezoneOverride() { Assert.That(async () => await bidi.Emulation.SetTimezoneOverrideAsync("UTC", new () { Contexts = [context] }), Throws.Nothing); } + + [Test] + public void CanSetUserAgentOverride() + { + Assert.That(async () => await bidi.Emulation.SetUserAgentOverrideAsync("MyUserAgent/1.0", new () { Contexts = [context] }), Throws.Nothing); + } } From de30f4b08c168af8dda91b96b39fb64e15b595e5 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 18:11:16 +0300 Subject: [PATCH 04/12] SetLocale --- .../Json/BiDiJsonSerializerContext.cs | 1 + .../BiDi/Emulation/EmulationModule.cs | 7 ++++ .../Emulation/SetLocaleOverrideCommand.cs | 36 +++++++++++++++++++ .../Emulation/SetTimezoneOverrideCommand.cs | 5 +-- .../Emulation/SetUserAgentOverrideCommand.cs | 5 +-- .../common/BiDi/Emulation/EmulationTest.cs | 9 +++++ 6 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverrideCommand.cs diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index db0fd712c3171..c0ba27623b7bb 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -174,5 +174,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(WebExtension.UninstallCommand))] [JsonSerializable(typeof(Emulation.SetTimezoneOverrideCommand))] [JsonSerializable(typeof(Emulation.SetUserAgentOverrideCommand))] +[JsonSerializable(typeof(Emulation.SetLocaleOverrideCommand))] internal partial class BiDiJsonSerializerContext : JsonSerializerContext; diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index ddc6266e00174..dccf4373db0f8 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -37,4 +37,11 @@ public async Task SetUserAgentOverrideAsync(string? userAgent, SetU return await Broker.ExecuteCommandAsync(new SetUserAgentOverrideCommand(@params), options).ConfigureAwait(false); } + + public async Task SetLocaleOverrideAsync(string? locale, SetLocaleOverrideOptions? options = null) + { + var @params = new SetLocaleOverrideParameters(locale, options?.Contexts, options?.UserContexts); + + return await Broker.ExecuteCommandAsync(new SetLocaleOverrideCommand(@params), options).ConfigureAwait(false); + } } diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverrideCommand.cs new file mode 100644 index 0000000000000..900178c9090e1 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverrideCommand.cs @@ -0,0 +1,36 @@ +// +// 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 System.Collections.Generic; +using System.Text.Json.Serialization; +using OpenQA.Selenium.BiDi.Communication; + +namespace OpenQA.Selenium.BiDi.Emulation; + +internal sealed class SetLocaleOverrideCommand(SetLocaleOverrideParameters @params) + : Command(@params, "emulation.setLocaleOverride"); + +internal sealed record SetLocaleOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? Locale, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; + +public sealed class SetLocaleOverrideOptions : CommandOptions +{ + public IEnumerable? Contexts { get; set; } + + public IEnumerable? UserContexts { get; set; } +} diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs index 90f3d3172045e..a3c24c25ff530 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs @@ -17,15 +17,16 @@ // under the License. // -using System.Collections.Generic; using OpenQA.Selenium.BiDi.Communication; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.Emulation; internal sealed class SetTimezoneOverrideCommand(SetTimezoneOverrideParameters @params) : Command(@params, "emulation.setTimezoneOverride"); -internal sealed record SetTimezoneOverrideParameters(string? Timezone, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetTimezoneOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? Timezone, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed class SetTimezoneOverrideOptions : CommandOptions { diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs index b8f90367fd89e..69467d6d5f9db 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs @@ -17,15 +17,16 @@ // under the License. // -using System.Collections.Generic; using OpenQA.Selenium.BiDi.Communication; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.Emulation; internal sealed class SetUserAgentOverrideCommand(SetUserAgentOverrideParameters @params) : Command(@params, "emulation.setUserAgentOverride"); -internal sealed record SetUserAgentOverrideParameters(string? UserAgent, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetUserAgentOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? UserAgent, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed class SetUserAgentOverrideOptions : CommandOptions { diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs index 30804a64f3393..02eac3290006f 100644 --- a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -27,11 +27,20 @@ class EmulationTest : BiDiTestFixture public void CanSetTimezoneOverride() { Assert.That(async () => await bidi.Emulation.SetTimezoneOverrideAsync("UTC", new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetTimezoneOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); } [Test] public void CanSetUserAgentOverride() { Assert.That(async () => await bidi.Emulation.SetUserAgentOverrideAsync("MyUserAgent/1.0", new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetUserAgentOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); + } + + [Test] + public void CanSetLocaleOverride() + { + Assert.That(async () => await bidi.Emulation.SetLocaleOverrideAsync("en-US", new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetLocaleOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); } } From 1af3dcb2a525cd928f359b46bba8d5ac3af4e734 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 18:24:13 +0300 Subject: [PATCH 05/12] SetForcedColorsModeTheme --- .../Json/BiDiJsonSerializerContext.cs | 1 + .../BiDi/Emulation/EmulationModule.cs | 9 +++- ...SetForcedColorsModeThemeOverrideCommand.cs | 42 +++++++++++++++++++ .../common/BiDi/Emulation/EmulationTest.cs | 7 ++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverrideCommand.cs diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index c0ba27623b7bb..564bccb5119f9 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -175,5 +175,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Emulation.SetTimezoneOverrideCommand))] [JsonSerializable(typeof(Emulation.SetUserAgentOverrideCommand))] [JsonSerializable(typeof(Emulation.SetLocaleOverrideCommand))] +[JsonSerializable(typeof(Emulation.SetForcedColorsModeThemeOverrideCommand))] internal partial class BiDiJsonSerializerContext : JsonSerializerContext; diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index dccf4373db0f8..e15879fc16ee8 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -9,7 +9,7 @@ // // http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, +// Unless required by applicable law or agreed 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 @@ -44,4 +44,11 @@ public async Task SetLocaleOverrideAsync(string? locale, SetLocaleO return await Broker.ExecuteCommandAsync(new SetLocaleOverrideCommand(@params), options).ConfigureAwait(false); } + + public async Task SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme? theme, SetForcedColorsModeThemeOverrideOptions? options = null) + { + var @params = new SetForcedColorsModeThemeOverrideParameters(theme, options?.Contexts, options?.UserContexts); + + return await Broker.ExecuteCommandAsync(new SetForcedColorsModeThemeOverrideCommand(@params), options).ConfigureAwait(false); + } } diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverrideCommand.cs new file mode 100644 index 0000000000000..eceb0920a0d98 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverrideCommand.cs @@ -0,0 +1,42 @@ +// +// 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 System.Collections.Generic; +using System.Text.Json.Serialization; +using OpenQA.Selenium.BiDi.Communication; + +namespace OpenQA.Selenium.BiDi.Emulation; + +internal sealed class SetForcedColorsModeThemeOverrideCommand(SetForcedColorsModeThemeOverrideParameters @params) + : Command(@params, "emulation.setForcedColorsModeThemeOverride"); + +internal sealed record SetForcedColorsModeThemeOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ForcedColorsModeTheme? Theme, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; + +public sealed class SetForcedColorsModeThemeOverrideOptions : CommandOptions +{ + public IEnumerable? Contexts { get; set; } + + public IEnumerable? UserContexts { get; set; } +} + +public enum ForcedColorsModeTheme +{ + Light, + Dark +} diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs index 02eac3290006f..53e9c4121e9d7 100644 --- a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -43,4 +43,11 @@ public void CanSetLocaleOverride() Assert.That(async () => await bidi.Emulation.SetLocaleOverrideAsync("en-US", new () { Contexts = [context] }), Throws.Nothing); Assert.That(async () => await bidi.Emulation.SetLocaleOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); } + + [Test] + public void CanSetForcedColorsModeThemeOverride() + { + Assert.That(async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme.Light, new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); + } } From a470cbc2c3fd58ef3e6605a9988a6cf86f33e1f2 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 18:28:11 +0300 Subject: [PATCH 06/12] SetScriptingEnabled --- .../Json/BiDiJsonSerializerContext.cs | 1 + .../BiDi/Emulation/EmulationModule.cs | 7 ++++ .../Emulation/SetScriptingEnabledCommand.cs | 36 +++++++++++++++++++ .../common/BiDi/Emulation/EmulationTest.cs | 7 ++++ 4 files changed, 51 insertions(+) create mode 100644 dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabledCommand.cs diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index 564bccb5119f9..ba56ec8539837 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -176,5 +176,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Emulation.SetUserAgentOverrideCommand))] [JsonSerializable(typeof(Emulation.SetLocaleOverrideCommand))] [JsonSerializable(typeof(Emulation.SetForcedColorsModeThemeOverrideCommand))] +[JsonSerializable(typeof(Emulation.SetScriptingEnabledCommand))] internal partial class BiDiJsonSerializerContext : JsonSerializerContext; diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index e15879fc16ee8..ef472ad6210c3 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -51,4 +51,11 @@ public async Task SetForcedColorsModeThemeOverrideAsync(ForcedColor return await Broker.ExecuteCommandAsync(new SetForcedColorsModeThemeOverrideCommand(@params), options).ConfigureAwait(false); } + + public async Task SetScriptingEnabledAsync(bool? enabled, SetScriptingEnabledOptions? options = null) + { + var @params = new SetScriptingEnabledParameters(enabled, options?.Contexts, options?.UserContexts); + + return await Broker.ExecuteCommandAsync(new SetScriptingEnabledCommand(@params), options).ConfigureAwait(false); + } } diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabledCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabledCommand.cs new file mode 100644 index 0000000000000..d19a9dfa4bf90 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabledCommand.cs @@ -0,0 +1,36 @@ +// +// 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 System.Collections.Generic; +using System.Text.Json.Serialization; +using OpenQA.Selenium.BiDi.Communication; + +namespace OpenQA.Selenium.BiDi.Emulation; + +internal sealed class SetScriptingEnabledCommand(SetScriptingEnabledParameters @params) + : Command(@params, "emulation.setScriptingEnabled"); + +internal sealed record SetScriptingEnabledParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] bool? Enabled, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; + +public sealed class SetScriptingEnabledOptions : CommandOptions +{ + public IEnumerable? Contexts { get; set; } + + public IEnumerable? UserContexts { get; set; } +} diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs index 53e9c4121e9d7..b656bb1362061 100644 --- a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -50,4 +50,11 @@ public void CanSetForcedColorsModeThemeOverride() Assert.That(async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme.Light, new () { Contexts = [context] }), Throws.Nothing); Assert.That(async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); } + + [Test] + public void CanSetScriptingEnabled() + { + Assert.That(async () => await bidi.Emulation.SetScriptingEnabledAsync(false, new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetScriptingEnabledAsync(null, new () { Contexts = [context] }), Throws.Nothing); + } } From c81121271f127e9579b3aa727e082f4a05d83841 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 18:41:12 +0300 Subject: [PATCH 07/12] SetScreenOrientation --- .../webdriver/BiDi/Communication/Broker.cs | 1 + .../Json/BiDiJsonSerializerContext.cs | 1 + .../ScreenOrientationTypeConverter.cs | 55 +++++++++++++++++++ .../BiDi/Emulation/EmulationModule.cs | 7 +++ .../SetScreenOrientationOverrideCommand.cs | 52 ++++++++++++++++++ .../common/BiDi/Emulation/EmulationTest.cs | 8 +++ 6 files changed, 124 insertions(+) create mode 100644 dotnet/src/webdriver/BiDi/Communication/Json/Converters/ScreenOrientationTypeConverter.cs create mode 100644 dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverrideCommand.cs diff --git a/dotnet/src/webdriver/BiDi/Communication/Broker.cs b/dotnet/src/webdriver/BiDi/Communication/Broker.cs index 77b592968b850..4292af05177d6 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Broker.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Broker.cs @@ -84,6 +84,7 @@ internal Broker(BiDi bidi, Uri url) new PreloadScriptConverter(_bidi), new RealmConverter(_bidi), new RealmTypeConverter(), + new ScreenOrientationTypeConverter(), new DateTimeOffsetConverter(), new PrintPageRangeConverter(), new InputOriginConverter(), diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index ba56ec8539837..114869d9858bb 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -177,5 +177,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Emulation.SetLocaleOverrideCommand))] [JsonSerializable(typeof(Emulation.SetForcedColorsModeThemeOverrideCommand))] [JsonSerializable(typeof(Emulation.SetScriptingEnabledCommand))] +[JsonSerializable(typeof(Emulation.SetScreenOrientationOverrideCommand))] internal partial class BiDiJsonSerializerContext : JsonSerializerContext; diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/ScreenOrientationTypeConverter.cs b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/ScreenOrientationTypeConverter.cs new file mode 100644 index 0000000000000..6027288f60278 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/ScreenOrientationTypeConverter.cs @@ -0,0 +1,55 @@ +// +// 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 System; +using System.Text.Json; +using System.Text.Json.Serialization; +using OpenQA.Selenium.BiDi.Emulation; + +namespace OpenQA.Selenium.BiDi.Communication.Json.Converters; + +internal class ScreenOrientationTypeConverter : JsonConverter +{ + public override ScreenOrientationType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + var str = reader.GetString(); + return str switch + { + "portrait-primary" => ScreenOrientationType.PortraitPrimary, + "portrait-secondary" => ScreenOrientationType.PortraitSecondary, + "landscape-primary" => ScreenOrientationType.LandscapePrimary, + "landscape-secondary" => ScreenOrientationType.LandscapeSecondary, + _ => throw new JsonException($"Unrecognized '{str}' value of {typeof(ScreenOrientationType)}."), + }; + } + + public override void Write(Utf8JsonWriter writer, ScreenOrientationType value, JsonSerializerOptions options) + { + var str = value switch + { + ScreenOrientationType.PortraitPrimary => "portrait-primary", + ScreenOrientationType.PortraitSecondary => "portrait-secondary", + ScreenOrientationType.LandscapePrimary => "landscape-primary", + ScreenOrientationType.LandscapeSecondary => "landscape-secondary", + _ => throw new JsonException($"Unrecognized '{value}' value of {typeof(ScreenOrientationType)}."), + }; + + writer.WriteStringValue(str); + } +} diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index ef472ad6210c3..acf750cddbf45 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -58,4 +58,11 @@ public async Task SetScriptingEnabledAsync(bool? enabled, SetScript return await Broker.ExecuteCommandAsync(new SetScriptingEnabledCommand(@params), options).ConfigureAwait(false); } + + public async Task SetScreenOrientationOverrideAsync(ScreenOrientation? screenOrientation, SetScreenOrientationOverrideOptions? options = null) + { + var @params = new SetScreenOrientationOverrideParameters(screenOrientation, options?.Contexts, options?.UserContexts); + + return await Broker.ExecuteCommandAsync(new SetScreenOrientationOverrideCommand(@params), options).ConfigureAwait(false); + } } diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverrideCommand.cs new file mode 100644 index 0000000000000..3e638d8ebb61b --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverrideCommand.cs @@ -0,0 +1,52 @@ +// +// 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 System.Collections.Generic; +using System.Text.Json.Serialization; +using OpenQA.Selenium.BiDi.Communication; + +namespace OpenQA.Selenium.BiDi.Emulation; + +internal sealed class SetScreenOrientationOverrideCommand(SetScreenOrientationOverrideParameters @params) + : Command(@params, "emulation.setScreenOrientationOverride"); + +internal sealed record SetScreenOrientationOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScreenOrientation? ScreenOrientation, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; + +public sealed class SetScreenOrientationOverrideOptions : CommandOptions +{ + public IEnumerable? Contexts { get; set; } + + public IEnumerable? UserContexts { get; set; } +} + +public enum ScreenOrientationNatural +{ + Portrait, + Landscape +} + +public enum ScreenOrientationType +{ + PortraitPrimary, + PortraitSecondary, + LandscapePrimary, + LandscapeSecondary +} + +public sealed record ScreenOrientation(ScreenOrientationNatural Natural, ScreenOrientationType Type); diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs index b656bb1362061..e86709958375f 100644 --- a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -57,4 +57,12 @@ public void CanSetScriptingEnabled() Assert.That(async () => await bidi.Emulation.SetScriptingEnabledAsync(false, new () { Contexts = [context] }), Throws.Nothing); Assert.That(async () => await bidi.Emulation.SetScriptingEnabledAsync(null, new () { Contexts = [context] }), Throws.Nothing); } + + [Test] + public void CanSetScreenOrientationOverride() + { + var orientation = new ScreenOrientation(ScreenOrientationNatural.Portrait, ScreenOrientationType.PortraitPrimary); + Assert.That(async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(orientation, new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); + } } From 1e75ae9c9d8a38fdc81343c0496953ae4eea6167 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 19:54:10 +0300 Subject: [PATCH 08/12] SetGeolocation --- .../Json/BiDiJsonSerializerContext.cs | 1 + .../BiDi/Emulation/EmulationModule.cs | 24 ++++++++ .../SetGeolocationOverrideCommand.cs | 61 +++++++++++++++++++ .../common/BiDi/Emulation/EmulationTest.cs | 32 ++++++---- 4 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index 114869d9858bb..4a74468315f4c 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -178,5 +178,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Emulation.SetForcedColorsModeThemeOverrideCommand))] [JsonSerializable(typeof(Emulation.SetScriptingEnabledCommand))] [JsonSerializable(typeof(Emulation.SetScreenOrientationOverrideCommand))] +[JsonSerializable(typeof(Emulation.SetGeolocationOverrideCommand))] internal partial class BiDiJsonSerializerContext : JsonSerializerContext; diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index acf750cddbf45..c06dc4604afd5 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -17,6 +17,7 @@ // under the License. // +using System; using System.Threading.Tasks; using OpenQA.Selenium.BiDi.Communication; @@ -65,4 +66,27 @@ public async Task SetScreenOrientationOverrideAsync(ScreenOrientati return await Broker.ExecuteCommandAsync(new SetScreenOrientationOverrideCommand(@params), options).ConfigureAwait(false); } + + public async Task SetGeolocationCoordinatesOverrideAsync(double latitude, double longitude, SetGeolocationCoordinatesOverrideOptions? options = null) + { + var coordinates = new GeolocationCoordinates(latitude, longitude, options?.Accuracy, options?.Altitude, options?.AltitudeAccuracy, options?.Heading, options?.Speed); + + var @params = new SetGeolocationOverrideCoordinatesParameters(coordinates, options?.Contexts, options?.UserContexts); + + return await Broker.ExecuteCommandAsync(new SetGeolocationOverrideCommand(@params), options).ConfigureAwait(false); + } + + public async Task SetGeolocationCoordinatesOverrideAsync(SetGeolocationOverrideOptions? options = null) + { + var @params = new SetGeolocationOverrideCoordinatesParameters(null, options?.Contexts, options?.UserContexts); + + return await Broker.ExecuteCommandAsync(new SetGeolocationOverrideCommand(@params), options).ConfigureAwait(false); + } + + public async Task SetGeolocationPositionErrorOverrideAsync(SetGeolocationPositionErrorOverrideOptions? options = null) + { + var @params = new SetGeolocationOverridePositionErrorParameters(new GeolocationPositionError(), options?.Contexts, options?.UserContexts); + + return await Broker.ExecuteCommandAsync(new SetGeolocationOverrideCommand(@params), options).ConfigureAwait(false); + } } diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs new file mode 100644 index 0000000000000..7db5406bb2fbc --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs @@ -0,0 +1,61 @@ +// +// 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 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 System.Collections.Generic; +using System.Text.Json.Serialization; +using OpenQA.Selenium.BiDi.Communication; + +namespace OpenQA.Selenium.BiDi.Emulation; + +internal sealed class SetGeolocationOverrideCommand(SetGeolocationOverrideParameters @params) + : Command(@params, "emulation.setGeolocationOverride"); + +[JsonDerivedType(typeof(SetGeolocationOverrideCoordinatesParameters))] +[JsonDerivedType(typeof(SetGeolocationOverridePositionErrorParameters))] +internal abstract record SetGeolocationOverrideParameters(IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; + +internal sealed record SetGeolocationOverrideCoordinatesParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] GeolocationCoordinates? Coordinates, IEnumerable? Contexts, IEnumerable? UserContexts) : SetGeolocationOverrideParameters(Contexts, UserContexts); + +internal sealed record SetGeolocationOverridePositionErrorParameters(GeolocationPositionError Error, IEnumerable? Contexts, IEnumerable? UserContexts) : SetGeolocationOverrideParameters(Contexts, UserContexts); + +internal sealed record GeolocationCoordinates(double Latitude, double Longitude, double? Accuracy, double? Altitude, double? AltitudeAccuracy, double? Heading, double? Speed); + +internal sealed record GeolocationPositionError +{ + [JsonInclude] + internal string Type { get; } = "positionUnavailable"; +} + +public class SetGeolocationOverrideOptions : CommandOptions +{ + public IEnumerable? Contexts { get; set; } + + public IEnumerable? UserContexts { get; set; } +} + +public sealed class SetGeolocationCoordinatesOverrideOptions : SetGeolocationOverrideOptions +{ + public double? Accuracy { get; set; } + public double? Altitude { get; set; } + public double? AltitudeAccuracy { get; set; } + public double? Heading { get; set; } + public double? Speed { get; set; } +} + +public sealed class SetGeolocationPositionErrorOverrideOptions : SetGeolocationOverrideOptions; diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs index e86709958375f..ddb37eb6474b2 100644 --- a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -26,43 +26,51 @@ class EmulationTest : BiDiTestFixture [Test] public void CanSetTimezoneOverride() { - Assert.That(async () => await bidi.Emulation.SetTimezoneOverrideAsync("UTC", new () { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetTimezoneOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetTimezoneOverrideAsync("UTC", new() { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetTimezoneOverrideAsync(null, new() { Contexts = [context] }), Throws.Nothing); } [Test] public void CanSetUserAgentOverride() { - Assert.That(async () => await bidi.Emulation.SetUserAgentOverrideAsync("MyUserAgent/1.0", new () { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetUserAgentOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetUserAgentOverrideAsync("MyUserAgent/1.0", new() { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetUserAgentOverrideAsync(null, new() { Contexts = [context] }), Throws.Nothing); } [Test] public void CanSetLocaleOverride() { - Assert.That(async () => await bidi.Emulation.SetLocaleOverrideAsync("en-US", new () { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetLocaleOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetLocaleOverrideAsync("en-US", new() { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetLocaleOverrideAsync(null, new() { Contexts = [context] }), Throws.Nothing); } [Test] public void CanSetForcedColorsModeThemeOverride() { - Assert.That(async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme.Light, new () { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme.Light, new() { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(null, new() { Contexts = [context] }), Throws.Nothing); } [Test] public void CanSetScriptingEnabled() { - Assert.That(async () => await bidi.Emulation.SetScriptingEnabledAsync(false, new () { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetScriptingEnabledAsync(null, new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetScriptingEnabledAsync(false, new() { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetScriptingEnabledAsync(null, new() { Contexts = [context] }), Throws.Nothing); } [Test] public void CanSetScreenOrientationOverride() { var orientation = new ScreenOrientation(ScreenOrientationNatural.Portrait, ScreenOrientationType.PortraitPrimary); - Assert.That(async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(orientation, new () { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(null, new () { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(orientation, new() { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(null, new() { Contexts = [context] }), Throws.Nothing); + } + + [Test] + public void CanSetGeolocationOverride() + { + Assert.That(async () => await bidi.Emulation.SetGeolocationCoordinatesOverrideAsync(0, 0, new() { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetGeolocationCoordinatesOverrideAsync(new() { Contexts = [context] }), Throws.Nothing); + Assert.That(async () => await bidi.Emulation.SetGeolocationPositionErrorOverrideAsync(new() { Contexts = [context] }), Throws.Nothing); } } From 4f253fa92b884ba191141c729bb4e5c0237b6e7e Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 20:22:38 +0300 Subject: [PATCH 09/12] Fix format --- dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs | 2 +- .../webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index c06dc4604afd5..69e48d464085d 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -9,7 +9,7 @@ // // http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed in writing, +// 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 diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs index 7db5406bb2fbc..00ff55da79319 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs @@ -9,7 +9,7 @@ // // http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed in writing, +// 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 From 0d810ced9f1041f8e8a1aa5521d5a398a5d99a4e Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 21:49:08 +0300 Subject: [PATCH 10/12] Ignoring not supported browsers --- .../common/BiDi/Emulation/EmulationTest.cs | 124 +++++++++++++++--- 1 file changed, 108 insertions(+), 16 deletions(-) diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs index ddb37eb6474b2..f1e980daf3654 100644 --- a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -24,53 +24,145 @@ namespace OpenQA.Selenium.BiDi.Emulation; class EmulationTest : BiDiTestFixture { [Test] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetTimezoneOverride() { - Assert.That(async () => await bidi.Emulation.SetTimezoneOverrideAsync("UTC", new() { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetTimezoneOverrideAsync(null, new() { Contexts = [context] }), Throws.Nothing); + Assert.That( + async () => await bidi.Emulation.SetTimezoneOverrideAsync("UTC", new() { Contexts = [context] }), + Throws.Nothing); } [Test] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] + public void CanSetTimezoneOverrideToDefault() + { + Assert.That( + async () => await bidi.Emulation.SetTimezoneOverrideAsync(null, new() { Contexts = [context] }), + Throws.Nothing); + } + + [Test] + [IgnoreBrowser(Selenium.Browser.Chrome, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Edge, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetUserAgentOverride() { - Assert.That(async () => await bidi.Emulation.SetUserAgentOverrideAsync("MyUserAgent/1.0", new() { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetUserAgentOverrideAsync(null, new() { Contexts = [context] }), Throws.Nothing); + Assert.That( + async () => await bidi.Emulation.SetUserAgentOverrideAsync("MyUserAgent/1.0", new() { Contexts = [context] }), + Throws.Nothing); + } + + [Test] + [IgnoreBrowser(Selenium.Browser.Chrome, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Edge, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] + public void CanSetUserAgentOverrideToDefault() + { + Assert.That( + async () => await bidi.Emulation.SetUserAgentOverrideAsync(null, new() { Contexts = [context] }), + Throws.Nothing); } [Test] public void CanSetLocaleOverride() { - Assert.That(async () => await bidi.Emulation.SetLocaleOverrideAsync("en-US", new() { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetLocaleOverrideAsync(null, new() { Contexts = [context] }), Throws.Nothing); + Assert.That( + async () => await bidi.Emulation.SetLocaleOverrideAsync("en-US", new() { Contexts = [context] }), + Throws.Nothing); } [Test] + public void CanSetLocaleOverrideToDefault() + { + Assert.That( + async () => await bidi.Emulation.SetLocaleOverrideAsync(null, new() { Contexts = [context] }), + Throws.Nothing); + } + + [Test] + [IgnoreBrowser(Selenium.Browser.Chrome, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Edge, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetForcedColorsModeThemeOverride() { - Assert.That(async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme.Light, new() { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(null, new() { Contexts = [context] }), Throws.Nothing); + Assert.That( + async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme.Light, new() { Contexts = [context] }), + Throws.Nothing); + } + + [Test] + [IgnoreBrowser(Selenium.Browser.Chrome, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Edge, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] + public void CanSetForcedColorsModeThemeOverrideToDefault() + { + Assert.That( + async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(null, new() { Contexts = [context] }), + Throws.Nothing); } [Test] + [IgnoreBrowser(Selenium.Browser.Chrome, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetScriptingEnabled() { - Assert.That(async () => await bidi.Emulation.SetScriptingEnabledAsync(false, new() { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetScriptingEnabledAsync(null, new() { Contexts = [context] }), Throws.Nothing); + Assert.That( + async () => await bidi.Emulation.SetScriptingEnabledAsync(false, new() { Contexts = [context] }), + Throws.Nothing); } [Test] + [IgnoreBrowser(Selenium.Browser.Chrome, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] + public void CanSetScriptingEnabledToDefault() + { + Assert.That( + async () => await bidi.Emulation.SetScriptingEnabledAsync(null, new() { Contexts = [context] }), + Throws.Nothing); + } + + [Test] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetScreenOrientationOverride() { var orientation = new ScreenOrientation(ScreenOrientationNatural.Portrait, ScreenOrientationType.PortraitPrimary); - Assert.That(async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(orientation, new() { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(null, new() { Contexts = [context] }), Throws.Nothing); + + Assert.That( + async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(orientation, new() { Contexts = [context] }), + Throws.Nothing); + } + + [Test] + [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] + public void CanSetScreenOrientationOverrideToDefault() + { + Assert.That( + async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(null, new() { Contexts = [context] }), + Throws.Nothing); + } + + [Test] + public void CanSetGeolocationCoordinatesOverride() + { + Assert.That( + async () => await bidi.Emulation.SetGeolocationCoordinatesOverrideAsync(0, 0, new() { Contexts = [context] }), + Throws.Nothing); + } + + [Test] + public void CanSetGeolocationCoordinatesOverrideToDefault() + { + Assert.That( + async () => await bidi.Emulation.SetGeolocationCoordinatesOverrideAsync(new() { Contexts = [context] }), + Throws.Nothing); } [Test] - public void CanSetGeolocationOverride() + [IgnoreBrowser(Selenium.Browser.Firefox, "invalid argument: Expected \"coordinates\" to be an object, got [object Undefined] undefined")] + public void CanSetGeolocationPositionErrorOverride() { - Assert.That(async () => await bidi.Emulation.SetGeolocationCoordinatesOverrideAsync(0, 0, new() { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetGeolocationCoordinatesOverrideAsync(new() { Contexts = [context] }), Throws.Nothing); - Assert.That(async () => await bidi.Emulation.SetGeolocationPositionErrorOverrideAsync(new() { Contexts = [context] }), Throws.Nothing); + Assert.That( + async () => await bidi.Emulation.SetGeolocationPositionErrorOverrideAsync(new() { Contexts = [context] }), + Throws.Nothing); } } From cd15fa1d32720daacedb9c34a08f5742a62ab877 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 21:52:19 +0300 Subject: [PATCH 11/12] Stylish --- .../common/BiDi/Emulation/EmulationTest.cs | 120 +++++++++++------- 1 file changed, 75 insertions(+), 45 deletions(-) diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs index f1e980daf3654..a094de8e6ff7b 100644 --- a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -27,18 +27,22 @@ class EmulationTest : BiDiTestFixture [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetTimezoneOverride() { - Assert.That( - async () => await bidi.Emulation.SetTimezoneOverrideAsync("UTC", new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetTimezoneOverrideAsync("UTC", new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetTimezoneOverrideToDefault() { - Assert.That( - async () => await bidi.Emulation.SetTimezoneOverrideAsync(null, new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetTimezoneOverrideAsync(null, new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] @@ -47,9 +51,11 @@ public void CanSetTimezoneOverrideToDefault() [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetUserAgentOverride() { - Assert.That( - async () => await bidi.Emulation.SetUserAgentOverrideAsync("MyUserAgent/1.0", new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetUserAgentOverrideAsync("MyUserAgent/1.0", new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] @@ -58,25 +64,31 @@ public void CanSetUserAgentOverride() [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetUserAgentOverrideToDefault() { - Assert.That( - async () => await bidi.Emulation.SetUserAgentOverrideAsync(null, new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetUserAgentOverrideAsync(null, new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] public void CanSetLocaleOverride() { - Assert.That( - async () => await bidi.Emulation.SetLocaleOverrideAsync("en-US", new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetLocaleOverrideAsync("en-US", new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] public void CanSetLocaleOverrideToDefault() { - Assert.That( - async () => await bidi.Emulation.SetLocaleOverrideAsync(null, new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetLocaleOverrideAsync(null, new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] @@ -85,9 +97,11 @@ public void CanSetLocaleOverrideToDefault() [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetForcedColorsModeThemeOverride() { - Assert.That( - async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme.Light, new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme.Light, new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] @@ -96,9 +110,11 @@ public void CanSetForcedColorsModeThemeOverride() [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetForcedColorsModeThemeOverrideToDefault() { - Assert.That( - async () => await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(null, new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetForcedColorsModeThemeOverrideAsync(null, new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] @@ -106,9 +122,11 @@ public void CanSetForcedColorsModeThemeOverrideToDefault() [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetScriptingEnabled() { - Assert.That( - async () => await bidi.Emulation.SetScriptingEnabledAsync(false, new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetScriptingEnabledAsync(false, new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] @@ -116,9 +134,11 @@ public void CanSetScriptingEnabled() [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetScriptingEnabledToDefault() { - Assert.That( - async () => await bidi.Emulation.SetScriptingEnabledAsync(null, new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetScriptingEnabledAsync(null, new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] @@ -127,42 +147,52 @@ public void CanSetScreenOrientationOverride() { var orientation = new ScreenOrientation(ScreenOrientationNatural.Portrait, ScreenOrientationType.PortraitPrimary); - Assert.That( - async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(orientation, new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetScreenOrientationOverrideAsync(orientation, new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetScreenOrientationOverrideToDefault() { - Assert.That( - async () => await bidi.Emulation.SetScreenOrientationOverrideAsync(null, new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetScreenOrientationOverrideAsync(null, new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] public void CanSetGeolocationCoordinatesOverride() { - Assert.That( - async () => await bidi.Emulation.SetGeolocationCoordinatesOverrideAsync(0, 0, new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetGeolocationCoordinatesOverrideAsync(0, 0, new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] public void CanSetGeolocationCoordinatesOverrideToDefault() { - Assert.That( - async () => await bidi.Emulation.SetGeolocationCoordinatesOverrideAsync(new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetGeolocationCoordinatesOverrideAsync(new() { Contexts = [context] }); + }, + Throws.Nothing); } [Test] [IgnoreBrowser(Selenium.Browser.Firefox, "invalid argument: Expected \"coordinates\" to be an object, got [object Undefined] undefined")] public void CanSetGeolocationPositionErrorOverride() { - Assert.That( - async () => await bidi.Emulation.SetGeolocationPositionErrorOverrideAsync(new() { Contexts = [context] }), - Throws.Nothing); + Assert.That(async () => + { + await bidi.Emulation.SetGeolocationPositionErrorOverrideAsync(new() { Contexts = [context] }); + }, + Throws.Nothing); } } From d7a7b50bb28cb2bd615d797d6e22b98a0da15ba7 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 4 Oct 2025 22:02:36 +0300 Subject: [PATCH 12/12] Ignore CanSetScriptingEnabled for Edge --- dotnet/test/common/BiDi/Emulation/EmulationTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs index a094de8e6ff7b..03d42b5822d4a 100644 --- a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -119,6 +119,7 @@ public void CanSetForcedColorsModeThemeOverrideToDefault() [Test] [IgnoreBrowser(Selenium.Browser.Chrome, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Edge, "Not supported yet?")] [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetScriptingEnabled() { @@ -131,6 +132,7 @@ public void CanSetScriptingEnabled() [Test] [IgnoreBrowser(Selenium.Browser.Chrome, "Not supported yet?")] + [IgnoreBrowser(Selenium.Browser.Edge, "Not supported yet?")] [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] public void CanSetScriptingEnabledToDefault() {