SeleniumHQ / SeleniumHQ/selenium

[🚀 Feature]: [dotnet] Web driver (options) builder

Open
#17,115 4 comments 0 reactions 0 assignees View on GitHub
A-needs-triaging C-dotnet I-enhancement J-stale
Dominant language
Java
Stars
34.5k
Forks
8.7k
Avg merge
2d 1h
Merged PRs (30d)
92

Description

### Description

Currently:
```csharp
var options = new ChromeOptions();
options.AddArgument("--a");
options.UseWebSocketUrl = true;
var chrome = new ChromeDriver(options);
```

### Have you considered any alternatives or workarounds?

```csharp
var chrome = new ChromeDriver(hd =>
{
hd.AddArguments("--a").UseWebSockeUrl();
});
```

Why:
Currently there are so many constructor overloads. And even all of them don't cover everything what it can opt-in. To specify `commandTimeout` I should use some constructor where `commandTimeout` is last argument. If we will support one more argument, then we should duplicate all constructors.

Conceptually, any WebDriver is:
1. DriverService (chromedriver.exe)
2. Browser options (Capabilities?)
3. HTTP client (transport)

WebDriverBuilder will be single entry point, allowing:
- Fluently describe what driver to start
- Configure driver service (even to be reusable if user wants)
- Configure HTTP low-level client

Pseudo example:
```csharp
var chrome = new ChromeDriver(hd =>
{
hd.WithVersion("145.1").
.WithService(s => s.UseFeatureA().UseFeatureB()) // or .WithService(_myExistingService)
.WithHttp(h => { h.DefaultHeaders.Add("x-name", "john"); h.UseProxy = false } );
});
```

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.