diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index 32c3335a61bb3..aa0ba1eca819c 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -119,7 +119,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Modules.BrowsingContext.UserPromptOpenedEventArgs))] [JsonSerializable(typeof(Modules.BrowsingContext.UserPromptClosedEventArgs))] -[JsonSerializable(typeof(Modules.BrowsingContext.Origin), TypeInfoPropertyName = "BrowsingContext_Origin")] [JsonSerializable(typeof(Modules.Network.BytesValue.String), TypeInfoPropertyName = "Network_BytesValue_String")] [JsonSerializable(typeof(Modules.Network.UrlPattern.String), TypeInfoPropertyName = "Network_UrlPattern_String")] diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs index 328644b8ed82b..bbede96ad4654 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs @@ -25,21 +25,21 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; internal class CaptureScreenshotCommand(CaptureScreenshotCommandParameters @params) : Command(@params, "browsingContext.captureScreenshot"); -internal record CaptureScreenshotCommandParameters(BrowsingContext Context, Origin? Origin, ImageFormat? Format, ClipRectangle? Clip) : CommandParameters; +internal record CaptureScreenshotCommandParameters(BrowsingContext Context, CaptureScreenshotOptions.ScreenshotOrigin? Origin, ImageFormat? Format, ClipRectangle? Clip) : CommandParameters; public record CaptureScreenshotOptions : CommandOptions { - public Origin? Origin { get; set; } + public ScreenshotOrigin? Origin { get; set; } public ImageFormat? Format { get; set; } public ClipRectangle? Clip { get; set; } -} -public enum Origin -{ - Viewport, - Document + public enum ScreenshotOrigin + { + Viewport, + Document + } } public record struct ImageFormat(string Type) @@ -48,14 +48,13 @@ public record struct ImageFormat(string Type) } [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] -[JsonDerivedType(typeof(Box), "box")] -[JsonDerivedType(typeof(Element), "element")] -public abstract record ClipRectangle -{ - public record Box(double X, double Y, double Width, double Height) : ClipRectangle; +[JsonDerivedType(typeof(BoxClipRectangle), "box")] +[JsonDerivedType(typeof(ElementClipRectangle), "element")] +public abstract record ClipRectangle; - public record Element([property: JsonPropertyName("element")] Script.ISharedReference SharedReference) : ClipRectangle; -} +public record BoxClipRectangle(double X, double Y, double Width, double Height) : ClipRectangle; + +public record ElementClipRectangle([property: JsonPropertyName("element")] Script.ISharedReference SharedReference) : ClipRectangle; public record CaptureScreenshotResult(string Data) { diff --git a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs index 59f451fe421e4..f5576d75d336a 100644 --- a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs +++ b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs @@ -259,8 +259,8 @@ public async Task CanCaptureScreenshotWithParameters() { var screenshot = await context.CaptureScreenshotAsync(new() { - Origin = Origin.Document, - Clip = new ClipRectangle.Box(5, 5, 10, 10) + Origin = CaptureScreenshotOptions.ScreenshotOrigin.Document, + Clip = new BoxClipRectangle(5, 5, 10, 10) }); Assert.That(screenshot, Is.Not.Null); @@ -272,8 +272,8 @@ public async Task CanCaptureScreenshotOfViewport() { var screenshot = await context.CaptureScreenshotAsync(new() { - Origin = Origin.Viewport, - Clip = new ClipRectangle.Box(5, 5, 10, 10) + Origin = CaptureScreenshotOptions.ScreenshotOrigin.Viewport, + Clip = new BoxClipRectangle(5, 5, 10, 10) }); Assert.That(screenshot, Is.Not.Null); @@ -289,7 +289,7 @@ public async Task CanCaptureScreenshotOfElement() var screenshot = await context.CaptureScreenshotAsync(new() { - Clip = new ClipRectangle.Element(nodes[0]) + Clip = new ElementClipRectangle(nodes[0]) }); Assert.That(screenshot, Is.Not.Null);