selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🚀 Feature]: Transition .NET to Async library

Open titusfortner opened this issue 1 year ago • 2 comments

Feature and motivation

.NET libraries are increasingly moving to Async implementations. Selenium should move over to be a completely Asynchronous library, especially since we plan to implement current methods with BiDi that have to be Async.

It is possible to maintain backwards compatibility by implementing existing Synchronous methods by calling the Async methods wrapped in a Run Task, but this doubles the API surface, and is not best practice.

Proposal

  1. Add Async methods to all classes
  2. Rewrite Sync methods to use the Async methods
  3. Write Blog Post talking about the proposed changes
  4. Mark all Sync methods as deprecated

#14051 is an example of doing the first 2 items for the Navigation methods

Question:

  1. Do we want to remove Sync methods for Selenium 5, knowing that Selenium 5 will be backwards incompatible with current Selenium code, or maintain both through Selenium 6?
  2. Need an answer to #14065 as part of this

attn: @jimevans / @nvborisenko / @YevgeniyShunevych

Usage example

await driver.FindElementAsync(By.Id("consoleLog"));

titusfortner avatar Jun 03 '24 16:06 titusfortner

I'm not sure which major version is better for removing sync API, but I think for WebDriver consumers, after adding async APIs, it will be good to keep deprecated (marked [Obsolete]) sync APIs for at least 3 minor version releases before removing. We'll need some time for such an upgrade.

YevgeniyShunevych avatar Jun 03 '24 18:06 YevgeniyShunevych

Are there any plans for the properties that call Sync methods? Ex: The Title property in WebDriver executes a driver command inside of a getter instead of providing a method. If a GetTitleAsync method were to be added, would a GetTitle method also be added and the property removed/deprecated?

Edit: another thing that would need to be considered is the constructors. Ex: the WebDriver constructor calls StartSession which executes a driver command but the constructor cannot be made async.

radmorecameron avatar Sep 03 '24 19:09 radmorecameron

v5 is a chance to make everything Async.

nvborisenko avatar Feb 08 '25 21:02 nvborisenko