Skip to content

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

@nvborisenko

Description

@nvborisenko

Description

Currently:

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

Have you considered any alternatives or workarounds?

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:

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 } );
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!C-dotnet.NET BindingsI-enhancementSomething could be better

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions