Asynchronous Bindings#

If you have code that executes an asynchronous task, you can define asynchronous bindings to execute the corresponding code using the async and await keywords.

The following example shows a step definition with an asynchronous When step:

Step Definition File#
[When(@"I want to get the web page '(.*)'")]
public async Task WhenIWantToGetTheWebPage(string url)
{
    var message = await _httpClient.GetAsync(url);
    // ...
}

Hint

You can also use asynchronous step argument transformations.

Hint

It is also possible to use ValueTask and ValueTask<T> return types.