Skip to content

Commit 5e35634

Browse files
committed
[dotnet] [bidi] Make Locator types as not nested
1 parent 0661b06 commit 5e35634

File tree

4 files changed

+22
-23
lines changed

4 files changed

+22
-23
lines changed

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/Locator.cs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,34 @@
2222
namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
2323

2424
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
25-
[JsonDerivedType(typeof(Accessibility), "accessibility")]
26-
[JsonDerivedType(typeof(Css), "css")]
27-
[JsonDerivedType(typeof(InnerText), "innerText")]
28-
[JsonDerivedType(typeof(XPath), "xpath")]
29-
public abstract record Locator
25+
[JsonDerivedType(typeof(AccessibilityLocator), "accessibility")]
26+
[JsonDerivedType(typeof(CssLocator), "css")]
27+
[JsonDerivedType(typeof(InnerTextLocator), "innerText")]
28+
[JsonDerivedType(typeof(XPathLocator), "xpath")]
29+
public abstract record Locator;
30+
31+
public record AccessibilityLocator(AccessibilityLocator.AccessibilityLocatorValue Value) : Locator
3032
{
31-
public record Accessibility(Accessibility.AccessibilityValue Value) : Locator
33+
public record AccessibilityLocatorValue
3234
{
33-
public record AccessibilityValue
34-
{
35-
public string? Name { get; set; }
36-
public string? Role { get; set; }
37-
}
35+
public string? Name { get; set; }
36+
public string? Role { get; set; }
3837
}
38+
}
3939

40-
public record Css(string Value) : Locator;
41-
42-
public record InnerText(string Value) : Locator
43-
{
44-
public bool? IgnoreCase { get; set; }
40+
public record CssLocator(string Value) : Locator;
4541

46-
public MatchType? MatchType { get; set; }
42+
public record InnerTextLocator(string Value) : Locator
43+
{
44+
public bool? IgnoreCase { get; set; }
4745

48-
public long? MaxDepth { get; set; }
49-
}
46+
public MatchType? MatchType { get; set; }
5047

51-
public record XPath(string Value) : Locator;
48+
public long? MaxDepth { get; set; }
5249
}
5350

51+
public record XPathLocator(string Value) : Locator;
52+
5453
public enum MatchType
5554
{
5655
Full,

dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public async Task CanCaptureScreenshotOfElement()
285285
{
286286
await context.NavigateAsync(UrlBuilder.WhereIs("formPage.html"), new() { Wait = ReadinessState.Complete });
287287

288-
var nodes = await context.LocateNodesAsync(new Locator.Css("#checky"));
288+
var nodes = await context.LocateNodesAsync(new CssLocator("#checky"));
289289

290290
var screenshot = await context.CaptureScreenshotAsync(new()
291291
{

dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public async Task TestShiftClickingOnMultiSelectionList()
6161
{
6262
driver.Url = UrlBuilder.WhereIs("formSelectionPage.html");
6363

64-
var options = await context.LocateNodesAsync(new Locator.Css("option"));
64+
var options = await context.LocateNodesAsync(new CssLocator("option"));
6565

6666
await context.Input.PerformActionsAsync([
6767
new PointerActions

dotnet/test/common/BiDi/Input/SetFilesTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public async Task CanSetFiles()
4545
{
4646
driver.Url = UrlBuilder.WhereIs("formPage.html");
4747

48-
var nodes = await context.LocateNodesAsync(new Locator.Css("[id='upload']"));
48+
var nodes = await context.LocateNodesAsync(new CssLocator("[id='upload']"));
4949

5050
await context.Input.SetFilesAsync(nodes[0], [_tempFile]);
5151

0 commit comments

Comments
 (0)