KakaoCup / Kakao

Nice and simple DSL for Espresso in Kotlin
https://kakaocup.github.io/Kakao/
Apache License 2.0
325 stars 28 forks source link

hasDrawable not working with imageview as excpected #32

Open TheReprator opened 3 years ago

TheReprator commented 3 years ago

Hi Team,

First thanks for this great UI Testing framework. Currently i am trying to check drawable with imageview but i am getting below error, as follows,

androidx.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'with drawable id -1 or provided instance' doesn't match the selected view. Expected: with drawable id -1 or provided instance Got: "AppCompatImageView{id=2131230883, res-name=factImage, visibility=VISIBLE, width=180, height=220, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=androidx.constraintlayout.widget.ConstraintLayout$LayoutParams@df6814a, tag=null, root-is-layout-requested=false, has-input-connection=false, x=508.0, y=65.0}"

Repository: https://github.com/TheReprator/Wipro/blob/image_error/appModules/factList/src/androidTest/kotlin/reprator/wipro/factlist/test/FactListKaspressoTest.kt

Test Name: imageViewDrawableComparison

Looking forward for a solution.

Regards, Vikram Singh

nkarapatstinkoff commented 2 years ago

Did you found a solution for vector drawable?

stknazev commented 1 year ago

@Vacxe One of the possible causes is using different Context in DrawableMatcher getResourceDrawable() uses InstrumentationRegistry.getInstrumentation().targetContext, and this may differ from context that uses view. In my case context inside view has a different theme, and drawable has theme attributes in it.