Appium Appium 怎么知道被测的程序是不是崩溃退出了?

GUO · 2013年11月27日 · 最后由 沙漠 回复于 2017年04月18日 · 2675 次阅读

好像只能在程序崩溃后继续 find 某一个控件,这样肯定会报错
能不能主动知道被测程序已经异常退出了
有没有什么办法?

共收到 6 条回复 时间 点赞

用 initial conditions test?
报错的时候,先捕获异常,然后看下被测程序是否已经异常退出了,如果退出了,就自定义自己的异常,否则就抛出捕获的异常?

GUO #2 · 2013年11月27日 Author

#1 楼 @lihuazhang 怎么看程序是否退出了?哪个接口? 你说的这个 initial conditions test 是啥东西

I feel like we see this message for other reasons too, like the app isn't compiled correctly. Also, restarting the app doesn't necessarily put it into a state where the test can continue. If the app crashes or dies, I think we should end the session and 500 the currently request.

https://github.com/appium/appium/issues/1147

#2 楼 @guo initial conditions test 是 Android 测试里面用的,就是 check 一些最基本的应用对象,来确保之后的测试是否有意义。

其实可以去 appium 的 Google group 问下,我估计没有什么好的解决方法。 @seveniruby

GUO #5 · 2013年12月05日 Author

#4 楼 @lihuazhang 可以通过 page_source 来判断,返回的不是个 json,一般就是已经退出了
目前我是这么觉得

判断当前页面的 activity 是否是应用的 activity,可以用来确定是否 crash 呢?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册