diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index 32c3335a61bb3..772ad709ce9e4 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -169,11 +169,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Modules.Input.PerformActionsCommand))] [JsonSerializable(typeof(Modules.Input.ReleaseActionsCommand))] [JsonSerializable(typeof(Modules.Input.SetFilesCommand))] -[JsonSerializable(typeof(Modules.Input.Pointer.Down), TypeInfoPropertyName = "Input_Pointer_Down")] -[JsonSerializable(typeof(Modules.Input.Pointer.Up), TypeInfoPropertyName = "Input_Pointer_Up")] -[JsonSerializable(typeof(Modules.Input.Pointer.Move), TypeInfoPropertyName = "Input_Pointer_Move")] -[JsonSerializable(typeof(Modules.Input.Key.Down), TypeInfoPropertyName = "Input_Key_Down")] -[JsonSerializable(typeof(Modules.Input.Key.Up), TypeInfoPropertyName = "Input_Key_Up")] [JsonSerializable(typeof(IEnumerable))] [JsonSerializable(typeof(IEnumerable))] [JsonSerializable(typeof(IEnumerable))] diff --git a/dotnet/src/webdriver/BiDi/Modules/Input/SourceActions.cs b/dotnet/src/webdriver/BiDi/Modules/Input/SourceActions.cs index a078c80fbf3fd..45e8e70edf79f 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Input/SourceActions.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Input/SourceActions.cs @@ -44,8 +44,8 @@ public record SourceActions : SourceActions, IEnumerable where [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] [JsonDerivedType(typeof(Pause), "pause")] -[JsonDerivedType(typeof(Key.Down), "keyDown")] -[JsonDerivedType(typeof(Key.Up), "keyUp")] +[JsonDerivedType(typeof(DownKey), "keyDown")] +[JsonDerivedType(typeof(UpKey), "keyUp")] public interface IKeySourceAction : ISourceAction; public record KeyActions : SourceActions @@ -54,8 +54,8 @@ public KeyActions Type(string text) { foreach (var character in text) { - Add(new Key.Down(character)); - Add(new Key.Up(character)); + Add(new DownKey(character)); + Add(new UpKey(character)); } return this; @@ -64,9 +64,9 @@ public KeyActions Type(string text) [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] [JsonDerivedType(typeof(Pause), "pause")] -[JsonDerivedType(typeof(Pointer.Down), "pointerDown")] -[JsonDerivedType(typeof(Pointer.Up), "pointerUp")] -[JsonDerivedType(typeof(Pointer.Move), "pointerMove")] +[JsonDerivedType(typeof(DownPointer), "pointerDown")] +[JsonDerivedType(typeof(UpPointer), "pointerUp")] +[JsonDerivedType(typeof(MovePointer), "pointerMove")] public interface IPointerSourceAction : ISourceAction; public record PointerActions : SourceActions @@ -76,7 +76,7 @@ public record PointerActions : SourceActions [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] [JsonDerivedType(typeof(Pause), "pause")] -[JsonDerivedType(typeof(Wheel.Scroll), "scroll")] +[JsonDerivedType(typeof(ScrollWheel), "scroll")] public interface IWheelSourceAction : ISourceAction; public record WheelActions : SourceActions; @@ -87,52 +87,49 @@ public interface INoneSourceAction : ISourceAction; public record NoneActions : SourceActions; -public abstract partial record Key : IKeySourceAction -{ - public record Down(char Value) : Key; +public abstract record Key : IKeySourceAction; - public record Up(char Value) : Key; -} +public record DownKey(char Value) : Key; + +public record UpKey(char Value) : Key; + +public abstract record Pointer : IPointerSourceAction; -public abstract record Pointer : IPointerSourceAction +public record DownPointer(int Button) : Pointer, IPointerCommonProperties { - public record Down(int Button) : Pointer, IPointerCommonProperties - { - public int? Width { get; set; } - public int? Height { get; set; } - public double? Pressure { get; set; } - public double? TangentialPressure { get; set; } - public int? Twist { get; set; } - public double? AltitudeAngle { get; set; } - public double? AzimuthAngle { get; set; } - } + public int? Width { get; set; } + public int? Height { get; set; } + public double? Pressure { get; set; } + public double? TangentialPressure { get; set; } + public int? Twist { get; set; } + public double? AltitudeAngle { get; set; } + public double? AzimuthAngle { get; set; } +} - public record Up(int Button) : Pointer; +public record UpPointer(int Button) : Pointer; - public record Move(int X, int Y) : Pointer, IPointerCommonProperties - { - public int? Duration { get; set; } +public record MovePointer(int X, int Y) : Pointer, IPointerCommonProperties +{ + public int? Duration { get; set; } - public Origin? Origin { get; set; } + public Origin? Origin { get; set; } - public int? Width { get; set; } - public int? Height { get; set; } - public double? Pressure { get; set; } - public double? TangentialPressure { get; set; } - public int? Twist { get; set; } - public double? AltitudeAngle { get; set; } - public double? AzimuthAngle { get; set; } - } + public int? Width { get; set; } + public int? Height { get; set; } + public double? Pressure { get; set; } + public double? TangentialPressure { get; set; } + public int? Twist { get; set; } + public double? AltitudeAngle { get; set; } + public double? AzimuthAngle { get; set; } } -public abstract record Wheel : IWheelSourceAction +public abstract record Wheel : IWheelSourceAction; + +public record ScrollWheel(int X, int Y, int DeltaX, int DeltaY) : Wheel { - public record Scroll(int X, int Y, int DeltaX, int DeltaY) : Wheel - { - public int? Duration { get; set; } + public int? Duration { get; set; } - public Origin? Origin { get; set; } - } + public Origin? Origin { get; set; } } public abstract record None : INoneSourceAction; diff --git a/dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs b/dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs index 2359cf12e0da0..8c8ef24f2c510 100644 --- a/dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs +++ b/dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs @@ -34,23 +34,23 @@ public async Task Paint() await Task.Delay(3000); await context.Input.PerformActionsAsync([new PointerActions { - new Pointer.Move(300, 300), - new Pointer.Down(0), - new Pointer.Move(400, 400) { Duration = 2000, Width = 1, Twist = 1 }, - new Pointer.Up(0), + new MovePointer(300, 300), + new DownPointer(0), + new MovePointer(400, 400) { Duration = 2000, Width = 1, Twist = 1 }, + new UpPointer(0), }]); await context.Input.PerformActionsAsync([new KeyActions { - new Key.Down('U'), - new Key.Up('U'), + new DownKey('U'), + new UpKey('U'), new Pause { Duration = 3000 } }]); await context.Input.PerformActionsAsync([new PointerActions { - new Pointer.Move(300, 300), - new Pointer.Down(0), - new Pointer.Move(400, 400) { Duration = 2000 }, - new Pointer.Up(0), + new MovePointer(300, 300), + new DownPointer(0), + new MovePointer(400, 400) { Duration = 2000 }, + new UpPointer(0), }]); await Task.Delay(3000); @@ -66,8 +66,8 @@ public async Task TestShiftClickingOnMultiSelectionList() await context.Input.PerformActionsAsync([ new PointerActions { - new Pointer.Down(1), - new Pointer.Up(1), + new DownPointer(1), + new UpPointer(1), } ]); }