[dotnet] add asynchronous methods to Navigation class#14051
[dotnet] add asynchronous methods to Navigation class#14051titusfortner merged 7 commits intotrunkfrom
Conversation
PR Review 🔍(Review updated until commit f50fd80)
Code feedback:
|
PR Code Suggestions ✨
|
|
/help |
PR Agent Walkthrough 🤖Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more. Here is a list of tools you can use to interact with the PR Agent:
(1) Note that each tool be triggered automatically when a new PR is opened, or called manually by commenting on a PR. (2) Tools marked with [*] require additional parameters to be passed. For example, to invoke the |
|
PR Description updated to latest commit (f50fd80)
|
|
Persistent review updated to latest commit f50fd80 |
PR Code Suggestions ✨
|
I think it is unnecessary in this context. I also would suggest to introduce kind of |
|
Agree with @nvborisenko. I would also keep sync-over-async implementation encapsulated in a class like this: internal static class AsyncHelper
{
internal static TResult RunSync<TResult>(Func<Task<TResult>> function) =>
Task.Run(function).GetAwaiter().GetResult();
internal static void RunSync(Func<Task> function) =>
Task.Run(function).GetAwaiter().GetResult();
} |
|
Abstracting out a helper class is out of scope for this PR. You can argue the best way to do that later; this is what the internet suggested I do (well, mostly) based on this particular execution. This is the user-facing API we want? I want to get something basic merged in before we start evaluating/comparing BiDi implementations |
|
If you land it now, than nobody will return to it back later. My internet is different https://devblogs.microsoft.com/dotnet/configureawait-faq/#can-i-use-task-run-to-avoid-using-configureawaitfalse: |
|
Nice, hadn't seen that, just the general advice that in a library every await should include a ConfigureAwait(false) |
That's fine too. That's a good indication that it doesn't actually matter. Really I just want to make sure that a different implementation won't require a different user-facing API, and that any changes you might want to make will work with this API. |
CI Failure Feedback 🧐(Checks updated until commit e037c9f)
✨ CI feedback usage guide:The CI feedback tool (
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR: where Configuration options
See more information about the |
|
updated to use |
|
Anyone should feel free to create helpers/abstractions for this and/or other code already in the library if it makes sense to do so. |
* allow driver to execute commands asynchronously * implement navigation commands with async tasks * dd async navigation methods to interface and implement in event firing webdriver * add explicit tests for navigation async methods * use async delegate with Task.Run instead of ConfigureAwait

User description
Description
Execute()onCommandExecutorclasses is already async, but has been made blocking; this PR now createsExecuteAsync()to bubble up the await toWebDriverExecute()methods remain blocking but now callExecuteAsync()ConfigureAwait(false)inside all async lambdas executed inTask.Run()that includeGetAwaiter().GetResult()at the endMotivation and Context
This is an example of a partial implementation of #14067
We explicitly want to maintain both Sync and Async implementations for the time being. (possibly until Selenium 6)
Questions
Follow on
CancellationTokenrecommendationattn: @YevgeniyShunevych
PR Type
Enhancement, Tests
Description
EventFiringWebDriver,INavigation, andNavigator.ExecuteAsyncmethod toICommandExecutor,DriverServiceCommandExecutor, andHttpCommandExecutor.ConfigureAwait(false)to all async calls to prevent deadlocks.Changes walkthrough 📝
7 files
EventFiringWebDriver.cs
Add asynchronous navigation methods to EventFiringWebDriverdotnet/src/support/Events/EventFiringWebDriver.cs
GoToUrl, Refresh).
ConfigureAwait(false)for all async calls.ICommandExecutor.cs
Add asynchronous command execution to ICommandExecutor interfacedotnet/src/webdriver/ICommandExecutor.cs
ExecuteAsyncmethod toICommandExecutorinterface.INavigation.cs
Add asynchronous navigation methods to INavigation interfacedotnet/src/webdriver/INavigation.cs
GoToUrl, Refresh).
Navigator.cs
Implement asynchronous navigation methods in Navigator classdotnet/src/webdriver/Navigator.cs
Forward, GoToUrl, Refresh).
DriverServiceCommandExecutor.cs
Add asynchronous command execution to DriverServiceCommandExecutordotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs
ExecuteAsyncmethod toDriverServiceCommandExecutor.Executemethod now calls the asynchronous version.HttpCommandExecutor.cs
Add asynchronous command execution to HttpCommandExecutordotnet/src/webdriver/Remote/HttpCommandExecutor.cs
ExecuteAsyncmethod toHttpCommandExecutor.Executemethod now calls the asynchronous version.WebDriver.cs
Add asynchronous internal command execution to WebDriverdotnet/src/webdriver/WebDriver.cs
InternalExecuteAsyncmethod for internal command execution.2 files
NavigationTest.cs
Add tests for asynchronous navigation methodsdotnet/test/common/NavigationTest.cs
EventFiringWebDriverTest.cs
Update tests for EventFiringWebDriver to use async methodsdotnet/test/support/Events/EventFiringWebDriverTest.cs