Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6dbe0d1

Browse files
nvborisenkosandeepsuryaprasad
authored andcommittedMar 23, 2025
[dotnet] [bidi] Make input Actions as not nested (SeleniumHQ#15437)
1 parent c25b0b0 commit 6dbe0d1

File tree

3 files changed

+52
-60
lines changed

3 files changed

+52
-60
lines changed
 

‎dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs

-5
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
164164
[JsonSerializable(typeof(Modules.Input.PerformActionsCommand))]
165165
[JsonSerializable(typeof(Modules.Input.ReleaseActionsCommand))]
166166
[JsonSerializable(typeof(Modules.Input.SetFilesCommand))]
167-
[JsonSerializable(typeof(Modules.Input.Pointer.Down), TypeInfoPropertyName = "Input_Pointer_Down")]
168-
[JsonSerializable(typeof(Modules.Input.Pointer.Up), TypeInfoPropertyName = "Input_Pointer_Up")]
169-
[JsonSerializable(typeof(Modules.Input.Pointer.Move), TypeInfoPropertyName = "Input_Pointer_Move")]
170-
[JsonSerializable(typeof(Modules.Input.Key.Down), TypeInfoPropertyName = "Input_Key_Down")]
171-
[JsonSerializable(typeof(Modules.Input.Key.Up), TypeInfoPropertyName = "Input_Key_Up")]
172167
[JsonSerializable(typeof(IEnumerable<Modules.Input.IPointerSourceAction>))]
173168
[JsonSerializable(typeof(IEnumerable<Modules.Input.IKeySourceAction>))]
174169
[JsonSerializable(typeof(IEnumerable<Modules.Input.INoneSourceAction>))]

‎dotnet/src/webdriver/BiDi/Modules/Input/SourceActions.cs

+40-43
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public record SourceActions<T> : SourceActions, IEnumerable<ISourceAction> where
4444

4545
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
4646
[JsonDerivedType(typeof(Pause), "pause")]
47-
[JsonDerivedType(typeof(Key.Down), "keyDown")]
48-
[JsonDerivedType(typeof(Key.Up), "keyUp")]
47+
[JsonDerivedType(typeof(DownKey), "keyDown")]
48+
[JsonDerivedType(typeof(UpKey), "keyUp")]
4949
public interface IKeySourceAction : ISourceAction;
5050

5151
public record KeyActions : SourceActions<IKeySourceAction>
@@ -54,8 +54,8 @@ public KeyActions Type(string text)
5454
{
5555
foreach (var character in text)
5656
{
57-
Add(new Key.Down(character));
58-
Add(new Key.Up(character));
57+
Add(new DownKey(character));
58+
Add(new UpKey(character));
5959
}
6060

6161
return this;
@@ -64,9 +64,9 @@ public KeyActions Type(string text)
6464

6565
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
6666
[JsonDerivedType(typeof(Pause), "pause")]
67-
[JsonDerivedType(typeof(Pointer.Down), "pointerDown")]
68-
[JsonDerivedType(typeof(Pointer.Up), "pointerUp")]
69-
[JsonDerivedType(typeof(Pointer.Move), "pointerMove")]
67+
[JsonDerivedType(typeof(DownPointer), "pointerDown")]
68+
[JsonDerivedType(typeof(UpPointer), "pointerUp")]
69+
[JsonDerivedType(typeof(MovePointer), "pointerMove")]
7070
public interface IPointerSourceAction : ISourceAction;
7171

7272
public record PointerActions : SourceActions<IPointerSourceAction>
@@ -76,7 +76,7 @@ public record PointerActions : SourceActions<IPointerSourceAction>
7676

7777
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
7878
[JsonDerivedType(typeof(Pause), "pause")]
79-
[JsonDerivedType(typeof(Wheel.Scroll), "scroll")]
79+
[JsonDerivedType(typeof(ScrollWheel), "scroll")]
8080
public interface IWheelSourceAction : ISourceAction;
8181

8282
public record WheelActions : SourceActions<IWheelSourceAction>;
@@ -87,52 +87,49 @@ public interface INoneSourceAction : ISourceAction;
8787

8888
public record NoneActions : SourceActions<None>;
8989

90-
public abstract partial record Key : IKeySourceAction
91-
{
92-
public record Down(char Value) : Key;
90+
public abstract record Key : IKeySourceAction;
9391

94-
public record Up(char Value) : Key;
95-
}
92+
public record DownKey(char Value) : Key;
93+
94+
public record UpKey(char Value) : Key;
95+
96+
public abstract record Pointer : IPointerSourceAction;
9697

97-
public abstract record Pointer : IPointerSourceAction
98+
public record DownPointer(int Button) : Pointer, IPointerCommonProperties
9899
{
99-
public record Down(int Button) : Pointer, IPointerCommonProperties
100-
{
101-
public int? Width { get; set; }
102-
public int? Height { get; set; }
103-
public double? Pressure { get; set; }
104-
public double? TangentialPressure { get; set; }
105-
public int? Twist { get; set; }
106-
public double? AltitudeAngle { get; set; }
107-
public double? AzimuthAngle { get; set; }
108-
}
100+
public int? Width { get; set; }
101+
public int? Height { get; set; }
102+
public double? Pressure { get; set; }
103+
public double? TangentialPressure { get; set; }
104+
public int? Twist { get; set; }
105+
public double? AltitudeAngle { get; set; }
106+
public double? AzimuthAngle { get; set; }
107+
}
109108

110-
public record Up(int Button) : Pointer;
109+
public record UpPointer(int Button) : Pointer;
111110

112-
public record Move(int X, int Y) : Pointer, IPointerCommonProperties
113-
{
114-
public int? Duration { get; set; }
111+
public record MovePointer(int X, int Y) : Pointer, IPointerCommonProperties
112+
{
113+
public int? Duration { get; set; }
115114

116-
public Origin? Origin { get; set; }
115+
public Origin? Origin { get; set; }
117116

118-
public int? Width { get; set; }
119-
public int? Height { get; set; }
120-
public double? Pressure { get; set; }
121-
public double? TangentialPressure { get; set; }
122-
public int? Twist { get; set; }
123-
public double? AltitudeAngle { get; set; }
124-
public double? AzimuthAngle { get; set; }
125-
}
117+
public int? Width { get; set; }
118+
public int? Height { get; set; }
119+
public double? Pressure { get; set; }
120+
public double? TangentialPressure { get; set; }
121+
public int? Twist { get; set; }
122+
public double? AltitudeAngle { get; set; }
123+
public double? AzimuthAngle { get; set; }
126124
}
127125

128-
public abstract record Wheel : IWheelSourceAction
126+
public abstract record Wheel : IWheelSourceAction;
127+
128+
public record ScrollWheel(int X, int Y, int DeltaX, int DeltaY) : Wheel
129129
{
130-
public record Scroll(int X, int Y, int DeltaX, int DeltaY) : Wheel
131-
{
132-
public int? Duration { get; set; }
130+
public int? Duration { get; set; }
133131

134-
public Origin? Origin { get; set; }
135-
}
132+
public Origin? Origin { get; set; }
136133
}
137134

138135
public abstract record None : INoneSourceAction;

‎dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs

+12-12
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ public async Task Paint()
3434
await Task.Delay(3000);
3535

3636
await context.Input.PerformActionsAsync([new PointerActions {
37-
new Pointer.Move(300, 300),
38-
new Pointer.Down(0),
39-
new Pointer.Move(400, 400) { Duration = 2000, Width = 1, Twist = 1 },
40-
new Pointer.Up(0),
37+
new MovePointer(300, 300),
38+
new DownPointer(0),
39+
new MovePointer(400, 400) { Duration = 2000, Width = 1, Twist = 1 },
40+
new UpPointer(0),
4141
}]);
4242

4343
await context.Input.PerformActionsAsync([new KeyActions {
44-
new Key.Down('U'),
45-
new Key.Up('U'),
44+
new DownKey('U'),
45+
new UpKey('U'),
4646
new Pause { Duration = 3000 }
4747
}]);
4848

4949
await context.Input.PerformActionsAsync([new PointerActions {
50-
new Pointer.Move(300, 300),
51-
new Pointer.Down(0),
52-
new Pointer.Move(400, 400) { Duration = 2000 },
53-
new Pointer.Up(0),
50+
new MovePointer(300, 300),
51+
new DownPointer(0),
52+
new MovePointer(400, 400) { Duration = 2000 },
53+
new UpPointer(0),
5454
}]);
5555

5656
await Task.Delay(3000);
@@ -66,8 +66,8 @@ public async Task TestShiftClickingOnMultiSelectionList()
6666
await context.Input.PerformActionsAsync([
6767
new PointerActions
6868
{
69-
new Pointer.Down(1),
70-
new Pointer.Up(1),
69+
new DownPointer(1),
70+
new UpPointer(1),
7171
}
7272
]);
7373
}

0 commit comments

Comments
 (0)
Please sign in to comment.