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.

A sample project using asynchronous bindings can be found here. The When binding in WebSteps.cs is asynchronous, and defined as follows:

[When(@"I want to get the web page '(.*)'")]
public async Task WhenIWantToGetTheWebPage(string url)
{
    await _webDriver.HttpClientGet(url);
}

The HTTPClientGet asynchronous task is defined in WebDriver.cs as follows:

public async Task HttpClientGet(string url)
{
    _httpResponseMessage = await _httpClient.GetAsync(url);
}

From SpecFlow v4 you can also use asynchronous step argument transformations.

From SpecFlow v4 you can also use ValueTask and ValueTask return types.