Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在使用Espresso2来测试按钮是否已启用.我的代码如下所示:onView(withId(R.id.fragment_vote_pause_btn)).check(matches(isEnabled()));我的按钮定义为:<Buttonandroid:id="@+id/fragment_vote_pause_btn"android:layout_width="wrap_content"

我正在使用Espresso 2来测试按钮是否已启用.我的代码如下所示:

  onVIEw(withID(R.ID.fragment_Vote_pause_btn)).check(matches(isEnabled()));

我的按钮定义为:

    <button        androID:ID="@+ID/fragment_Vote_pause_btn"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_alignParentBottom="true"        androID:layout_centerHorizontal="true"        androID:background="@androID:color/transparent"        androID:text="@string/audiowave_pause_or_play"        androID:textcolor="@drawable/play_pause_button_selector"        androID:textAllCaps="false"        androID:textSize="12sp" />

有时测试有效,但有时却出现以下异常:

androID.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'is enabled' doesn't match the selected vIEw.Expected: is enabledGot: "button{ID=2131296458, res-name=fragment_Vote_pause_btn, visibility=INVISIBLE, wIDth=329, height=144, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=false, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=375.0, y=649.0, text=Tap to play or pause, input-type=0, ime-target=false, has-links=false}"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:185)at androID.support.test.espresso.VIEwInteraction.check(VIEwInteraction.java:158)at be.appfoundry.IDentify.ui.VoteActivityTest.test2PlayPausebutton(VoteActivityTest.java:39)at java.lang.reflect.Method.invoke(Native Method)at java.lang.reflect.Method.invoke(Method.java:372)at androID.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)at androID.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)at androID.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)at junit.framework.TestCase.runbare(TestCase.java:134)at junit.framework.TestResult.protect(TestResult.java:115)at junit.framework.TestResult.runProtected(TestResult.java:133)at androID.support.test.internal.runner.junit3.DelegatingTestResult.runProtected(DelegatingTestResult.java:90)at junit.framework.TestResult.run(TestResult.java:118)at androID.support.test.internal.runner.junit3.AndroIDTestResult.run(AndroIDTestResult.java:49)at junit.framework.TestCase.run(TestCase.java:124)at androID.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63)at junit.framework.TestSuite.runTest(TestSuite.java:243)at junit.framework.TestSuite.run(TestSuite.java:238)at androID.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103)at androID.support.test.internal.runner.junit3.AndroIDTestSuite.run(AndroIDTestSuite.java:63)at androID.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)at org.junit.runners.Suite.runchild(Suite.java:128)at org.junit.runners.Suite.runchild(Suite.java:24)at org.junit.runners.ParentRunner.run(ParentRunner.java:231)at org.junit.runners.ParentRunner.schedule(ParentRunner.java:60)at org.junit.runners.ParentRunner.runchildren(ParentRunner.java:229)at org.junit.runners.ParentRunner.access
4)当您的按钮被阻止/不可见时的其他情况
0(ParentRunner.java:50)at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:222)at org.junit.runners.ParentRunner.run(ParentRunner.java:300)at org.junit.runner.JUnitCore.run(JUnitCore.java:157)at org.junit.runner.JUnitCore.run(JUnitCore.java:136)at androID.support.test.runner.AndroIDJUnitRunner.onStart(AndroIDJUnitRunner.java:270)at androID.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1837)Caused by: junit.framework.AssertionFailedError: 'is enabled' doesn't match the selected vIEw.Expected: is enabledGot: "button{ID=2131296458, res-name=fragment_Vote_pause_btn, visibility=INVISIBLE, wIDth=329, height=144, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=false, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=375.0, y=649.0, text=Tap to play or pause, input-type=0, ime-target=false, has-links=false}"at androID.support.test.espresso.matcher.VIEwMatchers.assertthat(VIEwMatchers.java:955)at androID.support.test.espresso.assertion.VIEwAssertions.check(VIEwAssertions.java:89)at androID.support.test.espresso.VIEwInteraction.run(VIEwInteraction.java:170)at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)at java.util.concurrent.FutureTask.run(FutureTask.java:237)at androID.os.Handler.handleCallback(Handler.java:739)at androID.os.Handler.dispatchMessage(Handler.java:95)at androID.os.Looper.loop(Looper.java:135)at androID.app.ActivityThread.main(ActivityThread.java:5221)at java.lang.reflect.Method.invoke(Native Method)at java.lang.reflect.Method.invoke(Method.java:372)at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:694)

有人知道吗?

解决方法:

在我看来,当您检查按钮是否启用时,您的按钮暂时不可见.

是不是正在检查尚未激活的窗口/按钮?也可能是 *** 作未同步,您必须等待使用空闲资源来启用/显示资源.
情况可能是:
1)活动未完全打开/加载(适配器等)
2)手势未完全完成(滚动等)
3)单击消息框后.[+++]

你是哪一个?出现故障时,您是否在设备屏幕上看到过?

此链接也可能有帮助-https://code.google.com/p/android-test-kit/wiki/EspressoSamples

总结

以上是内存溢出为你收集整理的java-Espresso“已启用”与所选视图不匹配全部内容,希望文章能够帮你解决java-Espresso“已启用”与所选视图不匹配所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
java-Espresso“已启用”与所选视图不匹配_app_内存溢出

java-Espresso“已启用”与所选视图不匹配

java-Espresso“已启用”与所选视图不匹配,第1张

概述我正在使用Espresso2来测试按钮是否已启用.我的代码如下所示:onView(withId(R.id.fragment_vote_pause_btn)).check(matches(isEnabled()));我的按钮定义为:<Buttonandroid:id="@+id/fragment_vote_pause_btn"android:layout_width="wrap_content"

我正在使用Espresso 2来测试按钮是否已启用.我的代码如下所示:

  onVIEw(withID(R.ID.fragment_Vote_pause_btn)).check(matches(isEnabled()));

我的按钮定义为:

    <button        androID:ID="@+ID/fragment_Vote_pause_btn"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_alignParentBottom="true"        androID:layout_centerHorizontal="true"        androID:background="@androID:color/transparent"        androID:text="@string/audiowave_pause_or_play"        androID:textcolor="@drawable/play_pause_button_selector"        androID:textAllCaps="false"        androID:textSize="12sp" />

有时测试有效,但有时却出现以下异常:

androID.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'is enabled' doesn't match the selected vIEw.Expected: is enabledGot: "button{ID=2131296458, res-name=fragment_Vote_pause_btn, visibility=INVISIBLE, wIDth=329, height=144, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=false, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=375.0, y=649.0, text=Tap to play or pause, input-type=0, ime-target=false, has-links=false}"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:185)at androID.support.test.espresso.VIEwInteraction.check(VIEwInteraction.java:158)at be.appfoundry.IDentify.ui.VoteActivityTest.test2PlayPausebutton(VoteActivityTest.java:39)at java.lang.reflect.Method.invoke(Native Method)at java.lang.reflect.Method.invoke(Method.java:372)at androID.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)at androID.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)at androID.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)at junit.framework.TestCase.runbare(TestCase.java:134)at junit.framework.TestResult.protect(TestResult.java:115)at junit.framework.TestResult.runProtected(TestResult.java:133)at androID.support.test.internal.runner.junit3.DelegatingTestResult.runProtected(DelegatingTestResult.java:90)at junit.framework.TestResult.run(TestResult.java:118)at androID.support.test.internal.runner.junit3.AndroIDTestResult.run(AndroIDTestResult.java:49)at junit.framework.TestCase.run(TestCase.java:124)at androID.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63)at junit.framework.TestSuite.runTest(TestSuite.java:243)at junit.framework.TestSuite.run(TestSuite.java:238)at androID.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103)at androID.support.test.internal.runner.junit3.AndroIDTestSuite.run(AndroIDTestSuite.java:63)at androID.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)at org.junit.runners.Suite.runchild(Suite.java:128)at org.junit.runners.Suite.runchild(Suite.java:24)at org.junit.runners.ParentRunner.run(ParentRunner.java:231)at org.junit.runners.ParentRunner.schedule(ParentRunner.java:60)at org.junit.runners.ParentRunner.runchildren(ParentRunner.java:229)at org.junit.runners.ParentRunner.access
4)当您的按钮被阻止/不可见时的其他情况
0(ParentRunner.java:50)at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:222)at org.junit.runners.ParentRunner.run(ParentRunner.java:300)at org.junit.runner.JUnitCore.run(JUnitCore.java:157)at org.junit.runner.JUnitCore.run(JUnitCore.java:136)at androID.support.test.runner.AndroIDJUnitRunner.onStart(AndroIDJUnitRunner.java:270)at androID.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1837)Caused by: junit.framework.AssertionFailedError: 'is enabled' doesn't match the selected vIEw.Expected: is enabledGot: "button{ID=2131296458, res-name=fragment_Vote_pause_btn, visibility=INVISIBLE, wIDth=329, height=144, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=false, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=375.0, y=649.0, text=Tap to play or pause, input-type=0, ime-target=false, has-links=false}"at androID.support.test.espresso.matcher.VIEwMatchers.assertthat(VIEwMatchers.java:955)at androID.support.test.espresso.assertion.VIEwAssertions.check(VIEwAssertions.java:89)at androID.support.test.espresso.VIEwInteraction.run(VIEwInteraction.java:170)at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)at java.util.concurrent.FutureTask.run(FutureTask.java:237)at androID.os.Handler.handleCallback(Handler.java:739)at androID.os.Handler.dispatchMessage(Handler.java:95)at androID.os.Looper.loop(Looper.java:135)at androID.app.ActivityThread.main(ActivityThread.java:5221)at java.lang.reflect.Method.invoke(Native Method)at java.lang.reflect.Method.invoke(Method.java:372)at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:694)

有人知道吗?

解决方法:

在我看来,当您检查按钮是否启用时,您的按钮暂时不可见.

是不是正在检查尚未激活的窗口/按钮?也可能是 *** 作未同步,您必须等待使用空闲资源来启用/显示资源.
情况可能是:
1)活动未完全打开/加载(适配器等)
2)手势未完全完成(滚动等)
3)单击消息框后.

你是哪一个?出现故障时,您是否在设备屏幕上看到过?

此链接也可能有帮助-https://code.google.com/p/android-test-kit/wiki/EspressoSamples

总结

以上是内存溢出为你收集整理的java-Espresso“已启用”与所选视图不匹配全部内容,希望文章能够帮你解决java-Espresso“已启用”与所选视图不匹配所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1211560.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存