diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs index 140d01e4b9bad..9d666f8427e53 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs @@ -62,7 +62,7 @@ public abstract record ClipRectangle { public record Box(double X, double Y, double Width, double Height) : ClipRectangle; - public record Element([property: JsonPropertyName("element")] Script.SharedReference SharedReference) : ClipRectangle; + public record Element([property: JsonPropertyName("element")] Script.ISharedReference SharedReference) : ClipRectangle; } public record CaptureScreenshotResult(string Data) diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs index 82ffd4c1fb301..cdf14ecbf1333 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs @@ -33,7 +33,7 @@ internal record LocateNodesCommandParameters(BrowsingContext Context, Locator Lo public Script.SerializationOptions? SerializationOptions { get; set; } - public IEnumerable<Script.SharedReference>? StartNodes { get; set; } + public IEnumerable<Script.ISharedReference>? StartNodes { get; set; } } public record LocateNodesOptions : CommandOptions @@ -42,7 +42,7 @@ public record LocateNodesOptions : CommandOptions public Script.SerializationOptions? SerializationOptions { get; set; } - public IEnumerable<Script.SharedReference>? StartNodes { get; set; } + public IEnumerable<Script.ISharedReference>? StartNodes { get; set; } } public record LocateNodesResult : IReadOnlyList<Script.RemoteValue.Node> diff --git a/dotnet/src/webdriver/BiDi/Modules/Input/Origin.cs b/dotnet/src/webdriver/BiDi/Modules/Input/Origin.cs index c4880aa356e4b..ad717c9427133 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Input/Origin.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Input/Origin.cs @@ -29,7 +29,7 @@ public record Viewport() : Origin; public record Pointer() : Origin; - public record Element([property: JsonPropertyName("element")] Script.SharedReference SharedReference) : Origin + public record Element([property: JsonPropertyName("element")] Script.ISharedReference SharedReference) : Origin { public string Type { get; } = "element"; } diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/RemoteReference.cs b/dotnet/src/webdriver/BiDi/Modules/Script/RemoteReference.cs index 4d6e4e3e12d55..95b69d0279a03 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/RemoteReference.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/RemoteReference.cs @@ -21,14 +21,16 @@ namespace OpenQA.Selenium.BiDi.Modules.Script; -public abstract record RemoteReference : LocalValue; +public interface IRemoteReference; -public record SharedReference(string SharedId) : RemoteReference +public interface ISharedReference : IRemoteReference { + public string SharedId { get; } + public Handle? Handle { get; set; } } -public record RemoteObjectReference(Handle Handle) : RemoteReference +public record RemoteObjectReference(Handle Handle) : IRemoteReference { public string? SharedId { get; set; } } diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs b/dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs index 9cce784f77517..a99855b78d957 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs @@ -246,7 +246,7 @@ public record HtmlCollection : RemoteValue public IReadOnlyList<RemoteValue>? Value { get; set; } } - public record Node : RemoteValue + public record Node : RemoteValue, ISharedReference { [JsonInclude] public string? SharedId { get; internal set; } diff --git a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs index 45e67e37892fa..59f451fe421e4 100644 --- a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs +++ b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs @@ -289,8 +289,7 @@ public async Task CanCaptureScreenshotOfElement() var screenshot = await context.CaptureScreenshotAsync(new() { - // TODO: Seems Node implements ISharedReference - Clip = new ClipRectangle.Element(new Modules.Script.SharedReference(nodes[0].SharedId)) + Clip = new ClipRectangle.Element(nodes[0]) }); Assert.That(screenshot, Is.Not.Null);