-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dotnet] add asynchronous methods to Navigation class #14051
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()
onCommandExecutor
classes is already async, but has been made blocking; this PR now createsExecuteAsync()
to bubble up the await toWebDriver
Execute()
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
CancellationToken
recommendationattn: @YevgeniyShunevych
PR Type
Enhancement, Tests
Description
EventFiringWebDriver
,INavigation
, andNavigator
.ExecuteAsync
method toICommandExecutor
,DriverServiceCommandExecutor
, andHttpCommandExecutor
.ConfigureAwait(false)
to all async calls to prevent deadlocks.Changes walkthrough 📝
7 files
EventFiringWebDriver.cs
Add asynchronous navigation methods to EventFiringWebDriver
dotnet/src/support/Events/EventFiringWebDriver.cs
GoToUrl, Refresh).
ConfigureAwait(false)
for all async calls.ICommandExecutor.cs
Add asynchronous command execution to ICommandExecutor interface
dotnet/src/webdriver/ICommandExecutor.cs
ExecuteAsync
method toICommandExecutor
interface.INavigation.cs
Add asynchronous navigation methods to INavigation interface
dotnet/src/webdriver/INavigation.cs
GoToUrl, Refresh).
Navigator.cs
Implement asynchronous navigation methods in Navigator class
dotnet/src/webdriver/Navigator.cs
Forward, GoToUrl, Refresh).
DriverServiceCommandExecutor.cs
Add asynchronous command execution to DriverServiceCommandExecutor
dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs
ExecuteAsync
method toDriverServiceCommandExecutor
.Execute
method now calls the asynchronous version.HttpCommandExecutor.cs
Add asynchronous command execution to HttpCommandExecutor
dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
ExecuteAsync
method toHttpCommandExecutor
.Execute
method now calls the asynchronous version.WebDriver.cs
Add asynchronous internal command execution to WebDriver
dotnet/src/webdriver/WebDriver.cs
InternalExecuteAsync
method for internal command execution.2 files
NavigationTest.cs
Add tests for asynchronous navigation methods
dotnet/test/common/NavigationTest.cs
EventFiringWebDriverTest.cs
Update tests for EventFiringWebDriver to use async methods
dotnet/test/support/Events/EventFiringWebDriverTest.cs