Skip to content

Commit

Permalink
[dotnet] [bidi] Convert RemoteRefrence to an interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko committed Dec 14, 2024
1 parent 89b84ae commit daf7356
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/BiDi/Modules/Input/Origin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
8 changes: 5 additions & 3 deletions dotnet/src/webdriver/BiDi/Modules/Script/RemoteReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit daf7356

Please sign in to comment.