@willosser Thanks for your reply...
Advertisements would display around 10-20 seconds on the screen.
It can come at any situation for example : when user lands on any screen then it may come or when user idle on the screen for some time then it may come. We can't predict when advertisement may come.
Regarding "factory design pattern to detect the screen you are on, and if it detects the advertisement, dismiss the advertisement and try again. If the latter, you could (sigh) wrap all actions in a try/catch block to check for MissingElement (or the equivalent exception) and if the exception is caught, check for advertisement, dismiss and retry if present.". Could you please give me some code for example regarding this approach.
Thanks very much!!