I have been running into a problem with the C# selenium bindings decribed here: Selenium Error - The HTTP request to the remote WebDriver timed out after 60 seconds
where a timeout exception is thrown occasionally while running my selenium tests. The tests are all written using spec flow, and I would love to have a way to catch that exception and have the test return as Inconclusive (instead of failed) for that particular exception.
Does anyone know of a way to wrap each spec flow scenario in a try catch block? Is that possible to do? Or a way to automatically catch this exception without having to wrap each individual step definition in a try catch block?
Thanks!
I found a workaround for this issue where I can check for the exception after each step using the [AfterStep] binding. This works for me, and tests that failed are now marked as inconclusive:
[AfterStep]
public void check()
{
var exception = ScenarioContext.Current.TestError;
if (exception is WebDriverException
&& exception.Message.Contains("The HTTP request to the remote WebDriver server for URL "))
{
Assert.Inconclusive(exception.Message);
}
}
Hopefully someone finds this helpful!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With