Skip to content
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 @@ -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")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
internal class CaptureScreenshotCommand(CaptureScreenshotCommandParameters @params)
: Command<CaptureScreenshotCommandParameters>(@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)
Expand All @@ -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)
{
Expand Down
10 changes: 5 additions & 5 deletions dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Loading