Thread
#compose
    k

    kagomez

    2 years ago
    Hi guys, is using Modifier object to something like,
    Button(onClick = { state.counter++ }, modifier = Modifier.tag("testTag"))
    but on my UiTests the method findByTag is not recognizing the button, any insights on this?
    Adam Powell

    Adam Powell

    2 years ago
    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
    Mihai Popa

    Mihai Popa

    2 years ago
    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 🙂
    Adam Powell

    Adam Powell

    2 years ago
    ah, listen to @Mihai Popa then instead of me on this 🙂
    k

    kagomez

    2 years ago
    @Mihai Popa I was reading the documentation; this TestTag acts in a similar way as preview? that is a kind of utility?
    @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