Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hasDrawable not working with imageview as excpected #32

Open
TheReprator opened this issue Jun 14, 2021 · 2 comments
Open

hasDrawable not working with imageview as excpected #32

TheReprator opened this issue Jun 14, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@TheReprator
Copy link

TheReprator commented Jun 14, 2021

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

@Vacxe Vacxe added the bug Something isn't working label Jun 16, 2021
@Vacxe Vacxe self-assigned this Jun 16, 2021
@nkarapatstinkoff
Copy link

Did you found a solution for vector drawable?

@stknazev
Copy link

stknazev commented Nov 27, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants