We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I have a problem with matching child nodes for the ComposeScreen. It works in simple cases but for the current screen it won’t work:
ComposeScreen
fun SimpleScreen() { Scaffold(Modifier.testTag(TestTag.SimpleScreen.Tag)) { Card { Text( "TestTitle", Modifier .padding(16.dp) .testTag(TestTag.SimpleScreen.Title) ) } } }
The following PageObject can’t find our title at this screen:
class KSimpleScreen(semanticsProvider: SemanticsNodeInteractionsProvider) : ComposeScreen<KSimpleScreen>( semanticsProvider = semanticsProvider, viewBuilderAction = { hasTestTag(TestTag.SimpleScreen.Tag) } ) { val title: KNode = child { hasTestTag(TestTag.SimpleScreen.Title) } }
It can be fixed by deleting child and using hasAnyAncestor matcher:
child
hasAnyAncestor
val title: KNode = KNode(semanticsProvider) { hasAnyAncestor((androidx.compose.ui.test.hasTestTag(TestTag.SimpleScreen.Tag))) hasTestTag(TestTag.SimpleScreen.Title) }
But it’s not convenient and it would be great if BaseNode had this matcher by default for the parent node or allowed to change this behavior.
The text was updated successfully, but these errors were encountered:
Also there is another problem with nested page objects. Because BaseNode inherits only direct parent node matchers but not all ancestors:
BaseNode
override val delegate: ComposeDelegate by lazy(LazyThreadSafetyMode.NONE) { ComposeDelegate( nodeProvider = NodeProvider( nodeMatcher = NodeMatcher( matcher = if (parentNode == null) nodeMatcher.matcher else hasParent(parentNode.nodeMatcher.matcher) and nodeMatcher.matcher, position = nodeMatcher.position, useUnmergedTree = nodeMatcher.useUnmergedTree ), semanticsProvider = semanticsProvider ), parentDelegate = parentNode?.delegate ) }
And it can be a problem for some cases. I think we should combine matchers from all ancestor nodes.
Sorry, something went wrong.
I will try to work on this issue
I've done it in #28
No branches or pull requests
Hi, I have a problem with matching child nodes for the
ComposeScreen
. It works in simple cases but for the current screen it won’t work:The following PageObject can’t find our title at this screen:
It can be fixed by deleting
child
and usinghasAnyAncestor
matcher:But it’s not convenient and it would be great if BaseNode had this matcher by default for the parent node or allowed to change this behavior.
The text was updated successfully, but these errors were encountered: