diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index 32c3335a61bb3..b59fa14279983 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -140,9 +140,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Modules.Network.FetchErrorEventArgs))] [JsonSerializable(typeof(Modules.Network.AuthRequiredEventArgs))] -[JsonSerializable(typeof(Modules.Script.Target.Realm), TypeInfoPropertyName = "Script_Target_Realm")] -[JsonSerializable(typeof(Modules.Script.Target.Context), TypeInfoPropertyName = "Script_Target_Context")] - [JsonSerializable(typeof(Modules.Script.AddPreloadScriptCommand))] [JsonSerializable(typeof(Modules.Script.AddPreloadScriptResult))] [JsonSerializable(typeof(Modules.Script.DisownCommand))] diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs index 4a30a3a25a14d..9506ad058d565 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs @@ -46,7 +46,7 @@ public async Task> GetRealmsAsync(GetRealmsOptions? opt public Task EvaluateAsync(string expression, bool awaitPromise, EvaluateOptions? options = null, ContextTargetOptions? targetOptions = null) { - var contextTarget = new Target.Context(context); + var contextTarget = new ContextTarget(context); if (targetOptions is not null) { @@ -65,7 +65,7 @@ public async Task> GetRealmsAsync(GetRealmsOptions? opt public Task CallFunctionAsync(string functionDeclaration, bool awaitPromise, CallFunctionOptions? options = null, ContextTargetOptions? targetOptions = null) { - var contextTarget = new Target.Context(context); + var contextTarget = new ContextTarget(context); if (targetOptions is not null) { diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/Target.cs b/dotnet/src/webdriver/BiDi/Modules/Script/Target.cs index c6dd5218c9130..186a15ce18bf1 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/Target.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/Target.cs @@ -21,16 +21,15 @@ namespace OpenQA.Selenium.BiDi.Modules.Script; -[JsonDerivedType(typeof(Realm))] -[JsonDerivedType(typeof(Context))] -public abstract record Target -{ - public record Realm([property: JsonPropertyName("realm")] Script.Realm Target) : Target; +[JsonDerivedType(typeof(RealmTarget))] +[JsonDerivedType(typeof(ContextTarget))] +public abstract record Target; + +public record RealmTarget(Realm Realm) : Target; - public record Context([property: JsonPropertyName("context")] BrowsingContext.BrowsingContext Target) : Target - { - public string? Sandbox { get; set; } - } +public record ContextTarget(BrowsingContext.BrowsingContext Context) : Target +{ + public string? Sandbox { get; set; } } public class ContextTargetOptions diff --git a/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs b/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs index c670a262e40e0..957b75eece58f 100644 --- a/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs +++ b/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs @@ -210,11 +210,11 @@ public async Task CanCallFunctionInARealm() var realms = await bidi.Script.GetRealmsAsync(); - await bidi.Script.CallFunctionAsync("() => { window.foo = 3; }", true, new Target.Realm(realms[0].Realm)); - await bidi.Script.CallFunctionAsync("() => { window.foo = 5; }", true, new Target.Realm(realms[1].Realm)); + 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)); - var res1 = await bidi.Script.CallFunctionAsync("() => window.foo", true, new Target.Realm(realms[0].Realm)); - var res2 = await bidi.Script.CallFunctionAsync("() => window.foo", true, new Target.Realm(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)); 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 df581f79fccf4..4d389643e808d 100644 --- a/dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs +++ b/dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs @@ -116,11 +116,11 @@ public async Task CanEvaluateInARealm() var realms = await bidi.Script.GetRealmsAsync(); - await bidi.Script.EvaluateAsync("window.foo = 3", true, new Target.Realm(realms[0].Realm)); - await bidi.Script.EvaluateAsync("window.foo = 5", true, new Target.Realm(realms[1].Realm)); + 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)); - var res1 = await bidi.Script.EvaluateAsync("window.foo", true, new Target.Realm(realms[0].Realm)); - var res2 = await bidi.Script.EvaluateAsync("window.foo", true, new Target.Realm(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)); Assert.That(res1, Is.EqualTo(3)); Assert.That(res2, Is.EqualTo(5));