SeleniumHQ / SeleniumHQ/selenium

[🚀 Feature]: [dotnet] [bidi] Polymorphic static factory

Open
#16,156 3 comments 0 reactions 0 assignees View on GitHub
A-needs decision B-devtools C-dotnet I-enhancement
Dominant language
Java
Stars
34.5k
Forks
8.7k
Avg merge
2d 1h
Merged PRs (30d)
92

Description

### Description

Currently:

```csharp
await _context.LocateNodesAsync(new InnerTextLocator("Sign In"));
```

It is nice low-level implementation. Basically `LocateNodesAsync` method accepts abstract `Locator`. It means when user writes a code he doesn't know which well-known inherited classes from `Locator` he may use. This is common issue in .NET.

### Have you considered any alternatives or workarounds?

How to resolve: introduce static factory.
```csharp
await _context.LocateNodesAsync(Locator.InnerText("Sign In"));
```

Very simple and useful. What about optional parameters? It will be implicitly available via:
```csharp
await _context.LocateNodesAsync(Locator.InnerText("Sign In") with { IgnoreCase = true });
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.