We are trying to take screenshots for each step.
Everything works fine. But we are not able to correlate the screenshots to the steps which created them.
Wha
Implementing your own LogTraceListener allows you to get the current Step Definition:
public class LogTraceListener : ITraceListener
{
static public string LastGherkinMessage;
public void WriteTestOutput(string message)
{
LastGherkinMessage = message;
Console.WriteLine(message);
}
public void WriteToolOutput(string message)
{
Console.WriteLine(message);
}
}
This needs to be registered in the SpecFlow section in App.Config:
Having done this, the LastGherkinMessage property will contain the text of the Step Definition just entered. You can access this from within the Step Definition or from anywhere else.