https://kotlinlang.org logo
k

kagomez

05/11/2020, 7:22 PM
Hi guys, is using Modifier object to something like,
Copy code
Button(onClick = { state.counter++ }, modifier = Modifier.tag("testTag"))
but on my UiTests the method findByTag is not recognizing the button, any insights on this?
a

Adam Powell

05/11/2020, 8:21 PM
If this is a
findByTag
that returns a
View
it won't work with compose; different kinds of tags attached to different kinds of objects 🙂
Compose generates UI out of smaller subcomponents than Views so the view-based test APIs can't get to the right level of granularity
m

Mihai Popa

05/11/2020, 8:29 PM
You need to use
TestTag
instead for testing,
Modifier.tag
is a mechanism used by layouts in a different context. We should probably clean this up 🙂
👌 1
a

Adam Powell

05/11/2020, 8:32 PM
ah, listen to @Mihai Popa then instead of me on this 🙂
k

kagomez

05/11/2020, 10:28 PM
@Mihai Popa I was reading the documentation; this TestTag acts in a similar way as preview? that is a kind of utility?
Copy code
@Composable fun TestTag(
    tag: "acceptButton", 
    children: acceptButton()
): Unit
?? is like that how it is supposed to work?
you know what… nvm for some reason I needed to clear cache and restart in order to see the object
5 Views