1

I have been running into a problem with the C# selenium bindings decribed here: https://stackoverflow.com/questions/22322596/

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!

1 Answer 1

2

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.