Scenario : "My application may escape control during UI automation to another application like the browser etc"
Solution : "I want to get back to my application which I am automating after it loses control and moves to another app so that I can proceed with my automation"
Tried : I can figure out if an application escapes control by checking the bundle id's after each action so that if the actual and current bundle id's differ I get to know that my application lost control.
I am blocked on how to proceed further in getting back to my application in case it moves out of control
Thank you for your time and effort in going through till the end :)
This is a limitation of the "sandbox" in iOS -- once your app loses focus, UIAutomation must terminate as well. You will need to launch another instruments session to automate the browser (or whatever application you're switching to).
See this question for some information on launching an automation session against those apps.