uiautomator异常: Could not detect idle state.

在单元测试中使用uiautomator进行ui测试,获取控件的的时候报错:

W/UiAutomatorBridge: Could not detect idle state.
                     java.util.concurrent.TimeoutException: No idle state with idle timeout: 500 within global timeout: 10000
                         at android.app.UiAutomation.waitForIdle(UiAutomation.java:589)
                         at android.support.test.uiautomator.UiAutomatorBridge.waitForIdle(UiAutomatorBridge.java:112)
                         at android.support.test.uiautomator.UiDevice.waitForIdle(UiDevice.java:639)
                         at android.support.test.uiautomator.UiDevice.waitForIdle(UiDevice.java:629)
                         at android.support.test.uiautomator.UiDevice.getDisplayRotation(UiDevice.java:794)
                         at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpWindowHierarchy(AccessibilityNodeInfoDumper.java:47)
                         at android.support.test.uiautomator.UiDevice.dumpWindowHierarchy(UiDevice.java:953)
                         at android.support.test.uiautomator.UiDevice.dumpWindowHierarchy(UiDevice.java:940)
                         at org.yws.testin.xml.XMLUtil.dump(XMLUtil.java:31)
                         at org.yws.testin.MyTest.t(MyTest.java:29)
                         at java.lang.reflect.Method.invoke(Native Method)
                         at java.lang.reflect.Method.invoke(Method.java:372)
                         at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
                         at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
                         at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
                         at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
                         at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
                         at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
                         at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
                         at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
                         at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
                         at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                         at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
                         at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
                         at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
                         at android.support.test.runner.AndroidJUnit4.run(AndroidJUnit4.java:101)
                         at org.junit.runners.Suite.runChild(Suite.java:128)
                         at org.junit.runners.Suite.runChild(Suite.java:27)
                         at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
                         at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
                         at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                         at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
                         at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
                         at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
                         at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
                         at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
                         at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
                         at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:384)
                         at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1846)
         

每个界面都是这样,请问

  1. 由于什么原因导致的这种现象呢,app界面开发不规范么?
  2. 这种情况下如何实现获取ui元素信息?

感激不尽!!!

阅读 5.2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题