Retry same findElement statement after handling unexpected popup
Problem :In my application, there is the unexpected popup shows up on any screen that makes test case fail. I can surround findelement with try-catch for most likely places but it may happen on any screen so this is not a good idea to cover every finelement statement with try-catch.
Approach : I would like to have mechanism if findlement is failed at any place due to unexpected pop up occurred, Framework should handle pop up and retry same find element statement one more time and return back to test execution to continue future steps.
After doing some research on Internet, I feel it can be done using WebDriverEventListener and tried but did not work.
Solution/Suggestion: Can someone please provide me solution or suggestion how this can be achieved.