Espresso throw " Error performing 'single click' on view” when it run on device in the cloud, but same test successfully run locally

别说谁变了你拦得住时间么 提交于 2019-12-24 12:43:22

问题


I fill up user name and password and press a button that sends the information over the network (Espresso Idling resource is implemented), in the application the next screen appears and I can see in logs that the information has being sent. But the test fails with error that it was not able to press the button: android.support.test.espresso.PerformException: Error performing 'single click' on view 'with id:

Log:

10-03 07:36:30.308: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.308: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.318: I/ViewInteraction(27742): Performing 'replace text' action on view with id: com._:id/user_name 10-03 07:36:30.358: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.358: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.358: I/ViewInteraction(27742): Performing 'replace text' action on view with id: com._:id/password 10-03 07:36:30.388: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.388: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.388: I/ViewInteraction(27742): Performing 'single click' action on view with id: com._:id/Button 10-03 07:36:30.398: I/InputDispatcher(3416): Delivering touch to (3959): action: 0x4, toolType: 0 10-03 07:36:30.398: I/InputDispatcher(3416): Delivering touch to (27742): action: 0x0, toolType: 0 10-03 07:36:30.398: D/ViewRootImpl(27742): ViewPostImeInputStage ACTION_DOWN 10-03 07:36:30.408: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.408: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.428: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.428: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.438: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.438: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.448: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.448: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.458: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.458: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.458: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.458: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.478: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.478: D/_IdlingResource(27742): _ is idle now! with: 0 10-03 07:36:30.488: I/InputDispatcher(3416): Delivering touch to (27742): action: 0x1, toolType: 0 10-03 07:36:30.498: D/Request(27742): method: 1 url: https://.

****** I removed Network calls **********

10-03 07:37:30.538: I/TestRunner(27742): android.support.test.espresso.PerformException: Error performing 'single click - At Coordinates: 719, 1367 and precision: 16, 16' on view 'with id: com.:id/Button'. 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:80) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:56) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87) 10-03 07:37:30.538: I/TestRunner(27742): at Pages._LinkAccountPage.clickOnLinkAccountButton(LinkAccountPage.java:62) 10-03 07:37:30.538: I/TestRunner(27742): at Pages._LinkAccountPage.linkAccount(LinkAccountPage.java:40) 10-03 07:37:30.538: I/TestRunner(27742): at JunitTest.Test_BaseEspresso.searchAndLinkBill(Test_BaseEspresso.java:138) 10-03 07:37:30.538: I/TestRunner(27742): at JunitTest_.Test_LinkFiCreditKycPayCurrentBalanceNewAchReceiptCancel.Test_LinkFiCreditKycPayCurrentBalanceNewAchReceiptCancel(Test_LinkFiCreditKycPayCurrentBalanceNewAchReceiptCancel.java:41) 10-03 07:37:30.538: I/TestRunner(27742): at java.lang.reflect.Method.invoke(Native Method) 10-03 07:37:30.538: I/TestRunner(27742): at java.lang.reflect.Method.invoke(Method.java:372) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:270) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.rules.RunRules.evaluate(RunRules.java:20) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.Suite.runChild(Suite.java:128) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.Suite.runChild(Suite.java:27) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runner.JUnitCore.run(JUnitCore.java:137) 10-03 07:37:30.538: I/TestRunner(27742): at org.junit.runner.JUnitCore.run(JUnitCore.java:115) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262) 10-03 07:37:30.538: I/TestRunner(27742): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1889) ************** note error below** 10-03 07:37:30.538: I/TestRunner(27742): Caused by: android.support.test.espresso.AppNotIdleException: Looped for 3585 iterations over 60 SECONDS. The following Idle Conditions failed . 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.espresso.IdlingPolicy.handleTimeout(IdlingPolicy.java:61) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:480) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:411) 10-03 07:37:30.538: I/TestRunner(27742): at android.support.test.espresso.base.UiControllerImpl.injectMo 10-03 07:37:30.538: I/TestRunner(27742): ----- end exception ----- 10-03 07:37:30.538: I/TestRunner(27742): finished: Test_LinkFiCreditKycPayCurrentBalanceNewAchReceiptCancel(JunitTest_.Test_LinkFiCreditKycPayCurrentBalanceNewAchReceiptCancel) 10-03 07:37:30.578: I/MonitoringInstrumentation(27742): Activities that are still in CREATED to STOPPED: 3 10-03 07:37:30.578: I/MonitoringInstrumentation(27742): Finishing activity: com..core.provider.AddProviderActivity@3f31fd61 10-03 07:37:30.578: V/ApplicationPolicy(3416): isApplicationStateBlocked userId 0 pkgname com. 10-03 07:37:30.578: V/ApplicationPolicy(3416): isApplicationStateBlocked userId 0 pkgname com._ 10-03 07:37:30.578: D/InputDispatcher(3416): Focused application set to: xxxx 10-03 07:37:30.588: I/ActivityManager(3416): Skip updateThumbnail for r=ActivityRecord{23d1bfe2 u0 com./.core.provider.AddProviderActivity t5 f} 10-03 07:37:30.588: I/MonitoringInstrumentation(27742): Finishing activity: com..core.overview.NewUserSignUpIntroScreen@18c65aea 10-03 07:37:30.598: I/MonitoringInstrumentation(27742): Finishing activity: com..core.provider.SearchProviderActivity@33d373f6 10-03 07:37:30.598: V/ApplicationPolicy(3416): isApplicationStateBlocked userId 0 pkgname com. 10-03 07:37:30.598: V/ApplicationPolicy(3416): isApplicationStateBlocked userId 0 pkgname com.google.android.apps.mtaas.backdrop 10-03 07:37:30.598: D/InputDispatcher(3416): Focused application set to: xxxx 10-03 07:37:30.598: D/MultiWindowConverter(3416): dismissGuide() : Before attaching the guide view, mForceDismissGuide : false 10-03 07:37:30.598: D/InputDispatcher(3416): Focus left window: 27742 10-03 07:37:30.598: I/TestRunner(27742): run finished: 1 tests, 1 failed, 0 ignored 10-03 07:37:30.608: I/System.out(27742): (HTTPLog)-Static: isSBSettingEnabled false 10-03 07:37:30.608: D/PointerIcon(3416): setMouseIconStyle1 pointerType: 1001 iconType:101 flag:0 pid:3416 uid:1000 10-03 07:37:30.608: D/PointerIcon(3416): setMouseCustomIcon IconType is same.101 10-03 07:37:30.608: D/EnterpriseController(2962): mIsMarkChainAdded is 0 mIsBlockChainAdded is 0 netId is 0 10-03 07:37:30.608: D/Netd(2962): getNetworkForDns: using netid 502 for uid 10207 10-03 07:37:30.608: D/Lifecycle(27742): onActivityPaused: core.provider.AddProviderActivity


回答1:


Usually this kind of error appears when you are working on a screen whose fields are hidden behind the soft keyboard. Thus, you should do a couple of things:

  1. Make the layout scrollable and using ViewActions.scrollTo perform the scroll to that field.
  2. Close que soft keyboard using ViewActions.closeSoftKeyboard

An example:

String OLD_PWD_INPUT = "Asdf1234;";
onView(withId(R.id.old_password)).perform(typeText(OLD_PWD_INPUT));
onView(withId(R.id.verify_new_password)).perform(closeSoftKeyboard());
onView(withId(R.id.change_password_button)).check(matches(not(isEnabled())));

String NEW_PWD_INPUT = "Asdf1235;";
onView(withId(R.id.new_password)).perform(scrollTo());
onView(withId(R.id.new_password)).perform(typeText(NEW_PWD_INPUT));
onView(withId(R.id.verify_new_password)).perform(closeSoftKeyboard());
onView(withId(R.id.change_password_button)).check(matches(isEnabled()));


来源:https://stackoverflow.com/questions/46715689/espresso-throw-error-performing-single-click-on-view-when-it-run-on-device

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