maestro
maestro copied to clipboard
App doesn't record tap on bottom nav item, but maestro marks as successful
Jetpack Compose app, code for the UI component in question:
BottomNavigationItem(
selected = selectedItem == Screen.FAVORITES,
onClick = { if (selectedItem != Screen.FAVORITES) navController.navigate(R.id.favoritesFragment) },
icon = {
Icon(Icons.Filled.Favorite, contentDescription = null)
},
label = { Text("Favorites", modifier = Modifier.semantics { contentDescription = "Favorites" }) }
)
Test yaml:
appId: dev.sanskar.pokedex
---
- launchApp
- tapOn: "Favorites"
Observed Behavior: https://user-images.githubusercontent.com/22092047/189587494-6662100b-77cb-48c6-81f6-17d3ca314e37.mp4
Even tried with a test tag (#101). Modified UI Code:
BottomNavigationItem(
selected = selectedItem == Screen.FAVORITES,
onClick = { if (selectedItem != Screen.FAVORITES) navController.navigate(R.id.favoritesFragment) },
icon = {
Icon(Icons.Filled.Favorite, contentDescription = null)
},
label = {
Text(
"Favorites",
modifier = Modifier
.testTag("favorites_bottom_nav")
.semantics { testTagsAsResourceId = true
}
) }
)
Test yaml:
appId: dev.sanskar.pokedex
---
- launchApp
- tapOn:
id: "favorites_bottom_nav"
The same behavior is observed.
In both cases, I can see "text" : "Favorites",
in the output of maestro hierarchy
.
Here's the hierarchy output for the first case:
hiearchy.txt
Note that Maestro will try to tap the Favorites button as soon as it sees it, which in this case might be during the loading phase. Could that perhaps be the reason? What happens if you press the "Favorites" button manually while the content is loading? Judging by the fact that test succeeded, it could indeed find the view, so the issue is somewhere else.
Even if the favorites item is clicked during the loading phase, the fragment would switch at least. That wasn't the case here.
APK for the app: https://github.com/sanskar10100/Pokedex/releases/download/v0.2/Pokedex.0.2.apk
Bottom Nav code: https://github.com/sanskar10100/Pokedex/blob/bd6b50acce68276788f7f8cf092c92528e8990ff/app/src/main/java/dev/sanskar/pokedex/ui/commons/Commons.kt#L360
@sanskar10100 If you are trying to use testTag
, verify that testTagsAsResourceId
semantics is enabled.
https://developer.android.com/jetpack/compose/testing#uiautomator-interop
I faced the same issue and turned out that I missed enabling this semantic property for the composable subtree.
Thanks for taking the time to raise this issue! There has been a lot of improvements and fixes on Maestro since this was raised so we’ll go ahead and close this one out as part of an issue cleanup - if you still experience issues, please open a new issue with reproduction steps. Thanks again for using maestro!
This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue. Thank you for helping keep us our issue tracker clean!