How to handle recovery scenario in my framework. In this framework I want to create some methods which work after catching exception. So that I can easily come back on the normal stage from any of the damaged situation during the execution of my script?

It is an eCommerce application share some scenario according to application from where i can put my recovery scenarios methods?

Please share some example as well so that I can easily understand

  • Hi Shailendra Rathore; sorry but your question is difficult to understand. Can you explain a bit further what you mean? – Vince Bowdren Aug 22 '16 at 9:47
  • Hi @VinceBowdren I want to prepare recovery scenario in my framework. After catching exception how can i recover from that situation during execution. – Shailendra Rathore Aug 22 '16 at 10:03
  • Do you have an example of an damaged situation? – Niels van Reijmersdal Aug 24 '16 at 6:54
  • @NielsvanReijmersdal Damaged situation is anything. It would be any type of exception its not specific. – Shailendra Rathore Aug 24 '16 at 6:56
  • I think we do not understand why you want to recover. If a test fails it fails. Why do you want to recover? What is the goal? – Niels van Reijmersdal Aug 24 '16 at 6:57

If I understand correctly, you want to verify that if some error happens, you can still use the site afterwards. Because damaged situation = failed test, and problem in your site, and you really should not keep going.

If that's the case, then, when one of your tests fails but another doesn't you can already see that application is back to normal stage, no?

Or you can try running failed tests again, there is some info: Restart failed test case automatically in testng/selenium

Alternatively you can implement error handling around your selenium methods (pseudo example).

Instead of:


Write recovery scenario:

void Recover(){
   do something

Look for exceptions:

void ClickAndRecover(element){
  try { driver.FindElement(element).Click(); }
  catch (couldnt click) { Recover(); }

Not for click specifically. But in my opinion it would be a bad practice.

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