Skip to content

[dotnet] [bidi] Make input Actions as not nested #15437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Modules.Input.IPointerSourceAction>))]
[JsonSerializable(typeof(IEnumerable<Modules.Input.IKeySourceAction>))]
[JsonSerializable(typeof(IEnumerable<Modules.Input.INoneSourceAction>))]
Expand Down
83 changes: 40 additions & 43 deletions dotnet/src/webdriver/BiDi/Modules/Input/SourceActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public record SourceActions<T> : SourceActions, IEnumerable<ISourceAction> 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<IKeySourceAction>
Expand All @@ -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;
Expand All @@ -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<IPointerSourceAction>
Expand All @@ -76,7 +76,7 @@ public record PointerActions : SourceActions<IPointerSourceAction>

[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
[JsonDerivedType(typeof(Pause), "pause")]
[JsonDerivedType(typeof(Wheel.Scroll), "scroll")]
[JsonDerivedType(typeof(ScrollWheel), "scroll")]
public interface IWheelSourceAction : ISourceAction;

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

public record NoneActions : SourceActions<None>;

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;
Expand Down
24 changes: 12 additions & 12 deletions dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
}
]);
}
Expand Down
Loading