如果我使用此方法在espresso测试中向上滑动,但在api级别23上不起作用。我收到此消息:
android.support.test.espresso.NoMatchingViewException:找不到层次结构中的视图匹配:with id:android:id / menu
另一方面,在api级别24中效果很好。我找不到答案,请帮助。
方法:
private ViewAction privateCustomSwipeUp(){
return new GeneralSwipeAction(Swipe.FAST, GeneralLucation.VISIBLE_CENTER,endCoorordinate(),Press.FINGER);
}
整个堆栈跟踪
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: android:id/menu
If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:android.widget.ListView{8a283a2 VFED.VC.. .F...... 0,0-864,1473 #102000a android:id/list}
View Hierarchy:
+>DecorView{id=-1, visibility=VISIBLE, width=960, height=1704, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+
.
.
.
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:580)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:82)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:53)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
at hu.user.tsmdashboardclient.activity.Helpers.TestHelper.swipeWhileElemVisibleWithText(TestHelper.java:171)
at hu.user.tsmdashboardclient.activity.Login.LoginBaseClass.typeNewValueToItem(LoginBaseClass.java:163)
at hu.user.tsmdashboardclient.activity.Login.LoginBaseClass.setRelay(LoginBaseClass.java:137)
at hu.user.tsmdashboardclient.activity.Login.LoginBaseClass.setPreferencies(LoginBaseClass.java:108)
at hu.user.tsmdashboardclient.activity.Login.LoginBaseClass.fixtures(LoginBaseClass.java:102)
at hu.user.tsmdashboardclient.activity.Login.SuccessfulLoginAndroidTest.successfulLoginTest(SuccessfulLoginAndroidTest.java:29)
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 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:257)
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 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:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:240)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1879)
java.lang.NullPointerException: Attempt to invoke interface method 'void hu.user.tsmdashboardclient.activity.IInitialView.setMainActivityToDefault()' on a null object reference
at hu.user.tsmdashboardclient.preferences.SettingsActivity.onDoneClicked(SettingsActivity.java:59)
at hu.user.tsmdashboardclient.preferences.SettingsActivity.onStop(SettingsActivity.java:86)
at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1278)
at android.support.test.runner.MonitoringInstrumentation.callActivityOnStop(MonitoringInstrumentation.java:557)
at android.app.Activity.performStop(Activity.java:6395)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3790)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3849)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
java.lang.RuntimeException: Unable to stop activity {hu.user.tsmdashboard.beta/hu.user.tsmdashboardclient.preferences.SettingsActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void hu.user.tsmdashboardclient.activity.IInitialView.setMainActivityToDefault()' on a null object reference
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3795)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3849)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void hu.user.tsmdashboardclient.activity.IInitialView.setMainActivityToDefault()' on a null object reference
at hu.user.tsmdashboardclient.preferences.SettingsActivity.onDoneClicked(SettingsActivity.java:59)
at hu.user.tsmdashboardclient.preferences.SettingsActivity.onStop(SettingsActivity.java:86)
at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1278)
at android.support.test.runner.MonitoringInstrumentation.callActivityOnStop(MonitoringInstrumentation.java:557)
at android.app.Activity.performStop(Activity.java:6395)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3790)
... 9 more
Test running failed: Instrumentation run failed due to 'java.lang.NullPointerException'