is enabled doesn't match the selected view
Closed this issue · 2 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
1. OnView on a button
2. matches isEnabled
What is the expected output? What do you see instead?
Expected: Espresso checks if the button is enabled or not
Instead:
ndroid.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCause
Error: 'is enabled' doesn't match the selected view.
Expected: is enabled
Got: "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(De
faultFailureHandler.java:82)
at
android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHa
ndler.java:53)
at
android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInt
eraction.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(ActivityInstrumentationTes
tCase2.java:192)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:115)
at junit.framework.TestResult.runProtected(TestResult.java:133)
at
android.support.test.internal.runner.junit3.DelegatingTestResult.runProtected(De
legatingTestResult.java:90)
at junit.framework.TestResult.run(TestResult.java:118)
at
android.support.test.internal.runner.junit3.AndroidTestResult.run(AndroidTestRes
ult.java:49)
at junit.framework.TestCase.run(TestCase.java:124)
at
android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(N
onLeakyTestSuite.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(DelegatingTe
stSuite.java:103)
at
android.support.test.internal.runner.junit3.AndroidTestSuite.run(AndroidTestSuit
e.java:63)
at
android.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassR
unner.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$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.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:2
70)
at
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1837)
Caused by: junit.framework.AssertionFailedError: 'is enabled' doesn't match the
selected view.
Expected: is enabled
Got: "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$2.check(ViewAssertions.ja
va:89)
at android.support.test.espresso.ViewInteraction$2.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)
What version of the product are you using? On what operating system?
Espresso 2.0 on os x
Code:
onView(withId(R.id.fragment_vote_pause_btn)).check(matches(isEnabled()));
Original issue reported on code.google.com by don.piro...@gmail.com
on 3 Feb 2015 at 12:20
GoogleCodeExporter commented
Well according to the espresso logs your button is disabled and actually not
visible at all. So the matcher works as expected.
I am using isEnabled matcher quite a lot and have never seen any problems with
it.
Try taking a screenshot right before the isEnabled check.
It also possible that your button is animating in when espresso performs it
check. In this case it is recommended to disable the animation in the
dev.options of your device.
Original comment by KAM...@gmail.com
on 7 Feb 2015 at 8:37
GoogleCodeExporter commented
Seems to be working as intended.
Original comment by vale...@google.com
on 16 Mar 2015 at 7:31
- Changed state: Invalid