Issue description: I have a test class which has multiple test cases. During the execution of one test the 'Page Could not be loaded' error occurs and driver times out as it does not find any element on page. While I can handle this particular situation by putting try catch statements but I need a way to instruct the driver that whenever it reaches on any such page it shall perform a set of actions (re-visit the site, perform login) and resume the testing from the very next test in current test class where it was stuck.

I'm using Selenium with C# and Nunit 3.0 framework.

2

There are 2 best solutions below

1
Leon Barkan On
try
{
   //your code
}
catch(TimeoutException ex)
{
   //go to home url
}
3
Krishnan Mahadevan On

You can try using the EventFiringWebDriver and leverage WebDriverExceptionEventArgs to eavesdrop into exceptions and see if that helps ? You can refer to the unit test EventFiringWebDriverTest to learn how to use it. That way your tests don't need to change.