Stack flop script in try-catch

I'm having a problem with the Selenium C # bindings described here: Selenium Error - HTTP request to remote WebDriver was disconnected after 60 seconds

when a timeout exception is thrown from time to time while running my selenium tests. All tests are written using a stream spec and I would like to be able to catch this exception and return the test result as Inconclusive (instead of failing) for that particular exception.

Does anyone know a way to wrap each BOM stream script in a try catch block? Can this be done? Or a way to automatically catch this exception without having to wrap every single step definition in a try catch block?

Thank!

+3


source to share


1 answer


I found a workaround for this problem where I can check for the exception after each step using the [AfterStep] binding. This works for me, and those tests that failed are now flagged 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);
        }
    }

      



Hope someone finds this helpful!

+8


source







All Articles