How does recovery scenario works in UFT? I mean how does UFT knows when to implement the recovery scenario during run time?
You create recovery Scenarios with a wizard in the UFT IDE. As part of the steps you can define what are the triggering criterias for this recovery scenario (Examples: Runtime error, a specific dialog appeared, at each step etc). If the recovery scneario is triggered there are actions what you can take in order to remedy the situation. Most of the time you want to execute a function and so on..... All this info is found in the Microfocus (HPE) Documentation.
What is less-known is that recovery scenario triggers are looking only at the steps in an Action. If you've gone away from an Action Based framework but use mostly functions to classify your keywords - well then recovery scenarios are useless for you - they are not triggered; just ignore them - and use plain old VBS error handling with lots of code and On Error Resume Next.
Recovery Scenarios are event-based while On Error Resume Next type error handlings have to be always deterministic (You always have to know where an unexpected popup may appear and handle it).
Long Story Short: The event-based nature of Recovery Scenarios would be a big advantage in error handling but it can be used only in an action based framework which on the other side is very bad with Resource Management and development easiness, so most people tend to abandon it