当我单击带有espresso测试用例的按钮时,即使按钮可见,它也会引发异常,并且它与espresso一起单击,应用程序移至其他活动,但由于该异常导致测试用例失败,不知道为什么。我对此进行了大量研究,但没有任何解决办法
我尝试过这样。
onView(withId(R.id.button_Login)).perform(click());
即使它显示但遇到相同的问题,并且我在应用程序中的不同事件上也遇到这种类型的问题,我都试图这样做。
onView(withId(R.id.button_Login)).check(matches(isDisplayed())).perform(click());
例外
android.support.test.espresso.PerformException: Error performing 'single click - At Coordinates: 359, 793 and precision: 16, 16' on view 'with id: com.retailistan.salesflo:id/button_Login'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:82)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:79)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:51)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312)
at android.support.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:173)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:114)
at com.retailistan.salesflo.espresso.StoreTaggingNew.performLogin(StoreTaggingNew.java:144)
at com.retailistan.salesflo.espresso.StoreTaggingNew.mainTest(StoreTaggingNew.java:100)
at java.lang.reflect.Method.invoke(Native Method)
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 android.support.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80)
at android.support.test.internal.runner.junit4.statement.RunAfters.evaluate(RunAfters.java:61)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:527)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
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:2075)
Caused by: android.support.test.espresso.AppNotIdleException: Looped for 5267 iterations over 60 SECONDS. The following Idle Conditions failed .
at android.support.test.espresso.IdlingPolicy.handleTimeout(IdlingPolicy.java:59)
at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:478)
at android.support.test.espresso.base.UiControllerImpl.loopMainThreadUntilIdle(UiControllerImpl.java:384)
at android.support.test.espresso.base.UiControllerImpl.injectMotionEvent(UiControllerImpl.java:251)
at android.support.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:140)
at android.support.test.espresso.action.MotionEvents.sendUp(MotionEvents.java:123)
at android.support.test.espresso.action.Tap.sendSingleTap(Tap.java:170)
at android.support.test.espresso.action.Tap.access$100(Tap.java:31)
at android.support.test.espresso.action.Tap$1.sendTap(Tap.java:47)
at android.support.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:136)
at android.support.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:356)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:248)
at android.support.test.espresso.ViewInteraction.access$100(ViewInteraction.java:63)
at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:153)
at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:150)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.Handler.handleCallback(Handler.java:795)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:6861)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:450)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)