I have a class which extends `AbstractComposeView`...
# compose
z
I have a class which extends
AbstractComposeView
that wraps our Button component, to allow our legacy XML pages to make use of the component. In our existing UI tests we have espresso calls like
onView(withId(id)).perform(click())
. When using this method on the Compose view, no click event is triggered. Has anyone else run into this/know of a fix?
l
Espresso cannot see elements inside compose views
I dont know if this is exactly your problem, but maybe it could be that
However, If you dont want to change your tests, you can use UiAutomation to find these elements
z
An espresso version bump fixed it! I am curious though, if I run into other issues what would UiAutomation do for me?
l
really? I didn't know that, so now with espresso you can find composables?
z
I didn’t have to make any code changes, i think it may have just been a bug
l
the famous flaky tests (? 😄
z
Copy code
// has a Composable inside
<OurComposeButton 
    android:id="@+id/ourButton" />
onView(withId(R.id.ourButton)).perform(click())
l
UiAutomation (as far as I know) uses accessibility features to find widgets, so its more useful to test more general stuff (or in scenarios where you cant use espresso)
z
ah got it
l
OurComposeButton inherits from AndroidComposeView, right? if thats the case, it should work fine with espresso 👌
z
yeah it does, once I got onto the latest espresso version the click started working
d
UIAutomator let you find elements on screen and interact with them, regardless of those elements been part of your app or the OS. (for example you can press OS permissions buttons)
105 Views