How to continue testing an iOS app, using UIAutomation instrument, even after the app exits?

天大地大妈咪最大 提交于 2019-12-04 04:42:04

This is not possible because Instruments loses the connection with the app process once it quits.

If you are scripting UI Automation from the command line, you can run a second automation script after the first one quits the app that then checks to make sure everything is reset.

instruments \
    -D [trace document] \
    -t [instruments template] \
    /path/to/Bundle.app \
    -e UIARESULTSPATH [directory to store test output] \
    -e UIASCRIPT reset_the_app.js

instruments \
    -D [trace document] \
    -t [instruments template] \
    /path/to/Bundle.app \
    -e UIARESULTSPATH [directory to store test output] \
    -e UIASCRIPT check_that_the_app_is_reset.js

So, rather than trying to get the same instance of Instruments to relaunch and reattach to the app, just run two separate scripts, one that does your reset-and-abort, and the other that checks the resulting state of the app.

user2461370

You can Use:

UIATarget.localTarget().deactivateAppForDuration(n); 

where n is the number of seconds you want this app to restart. I hope this helps.

thanks for the answers, but the documentation says:

"When a user exits your app by tapping the Home button or causing some other app to come to the foreground, your app is suspended."

So its not restarting but suspended?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!