Skip to content

Commit fe43278

Browse files
nvborisenkosandeepsuryaprasad
authored andcommitted
[dotnet] [bidi] Make Locator types as not nested (SeleniumHQ#15429)
1 parent 67cbc68 commit fe43278

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

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

+29-24
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,42 @@
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(ContextLocator), "context")]
28+
[JsonDerivedType(typeof(InnerTextLocator), "innerText")]
29+
[JsonDerivedType(typeof(XPathLocator), "xpath")]
30+
public abstract record Locator;
31+
32+
public record AccessibilityLocator(AccessibilityLocator.AccessibilityLocatorValue Value) : Locator
3033
{
31-
public record Accessibility(Accessibility.AccessibilityValue Value) : Locator
34+
public record AccessibilityLocatorValue
3235
{
33-
public record AccessibilityValue
34-
{
35-
public string? Name { get; set; }
36-
public string? Role { get; set; }
37-
}
36+
public string? Name { get; set; }
37+
public string? Role { get; set; }
3838
}
39+
}
3940

40-
public record Css(string Value) : Locator;
41+
public record CssLocator(string Value) : Locator;
4142

42-
public record InnerText(string Value) : Locator
43-
{
44-
public bool? IgnoreCase { get; set; }
43+
public record ContextLocator(ContextLocator.ContextLocatorValue Value) : Locator
44+
{
45+
public record ContextLocatorValue(BrowsingContext Context);
46+
}
4547

46-
public MatchType? MatchType { get; set; }
48+
public record InnerTextLocator(string Value) : Locator
49+
{
50+
public bool? IgnoreCase { get; set; }
4751

48-
public long? MaxDepth { get; set; }
49-
}
52+
public Match? MatchType { get; set; }
5053

51-
public record XPath(string Value) : Locator;
52-
}
54+
public long? MaxDepth { get; set; }
5355

54-
public enum MatchType
55-
{
56-
Full,
57-
Partial
56+
public enum Match
57+
{
58+
Full,
59+
Partial
60+
}
5861
}
62+
63+
public record XPathLocator(string Value) : Locator;

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

+1-1
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

+1-1
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

+1-1
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)