Thanks for releasing this feature, I have been experimenting with Kakao and have successfully used it for Espresso and Espresso web views, and now I'm testing the Compose views. The app I'm testing contains all these components.
The problem I'm having is that I cannot get a testTag to match, even though it works fine with raw Compose [ like this: composeTestRule.onNode(androidx.compose.ui.test.hasTestTag(“MyStatusArea")).assertIsDisplayed() ]
I was hoping that you might spot some issue in my tree log. I'm a newbie to Compose, but have been successful in using the raw Compose functions.
Kind Regards,
Pentti
This is the Exception I get when using Kakao Compose:
java.lang.AssertionError: Failed to perform isDisplayed check.
Can't retrieve node at index '0' of '((isRoot).children).filter(TestTag = 'MyStatusArea')'
There are no existing nodes for that selector.
at androidx.compose.ui.test.SemanticsNodeInteraction.fetchOneOrDie(SemanticsNodeInteraction.kt:169)
at androidx.compose.ui.test.SemanticsNodeInteraction.fetchSemanticsNode(SemanticsNodeInteraction.kt:106)
at androidx.compose.ui.test.AndroidAssertions_androidKt.checkIsDisplayed(AndroidAssertions.android.kt:29)
at androidx.compose.ui.test.AssertionsKt.assertIsDisplayed(Assertions.kt:33)
at io.github.kakaocup.compose.node.NodeAssertions$DefaultImpls.assertIsDisplayed(NodeAssertions.kt:11)
at io.github.kakaocup.compose.node.KNode.assertIsDisplayed(KNode.kt:7)
I've followed the sample and have this in my page object:
val statusArea = KNode(this) {
hasTestTag(“MyStatusArea")
}
And my test scenario contains:
onComposeScreen(composeTestRule) {
statusArea {
assertIsDisplayed()
}
}
I've logged the tree using this command:
composeTestRule.onRoot(useUnmergedTree = true).printToLog("COMPOSE_LOG")
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: printToLog:
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: Printing with useUnmergedTree = 'true'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: Node #1 at (l=0.0, t=171.0, r=1080.0, b=2148.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: |-Node #2 at (l=0.0, t=171.0, r=1080.0, b=2148.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: VerticalScrollAxisRange = 'androidx.compose.ui.semantics.ScrollAxisRange@db65b2a'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: Actions = [ScrollBy]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: |-Node #3 at (l=0.0, t=699.0, r=1080.0, b=699.0)px, Tag: 'MyCircleProgress'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: |-Node #4 at (l=342.0, t=501.0, r=738.0, b=897.0)px, Tag: 'MyButton'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Role = 'Button'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | [Disabled]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Actions = [OnClick]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | MergeDescendants = 'true'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | |-Node #6 at (l=447.0, t=626.0, r=633.0, b=685.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | Text = ‘[Waiting]’
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | Actions = [GetTextLayoutResult]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | |-Node #8 at (l=471.0, t=685.0, r=610.0, b=773.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | Text = '[1.9%]'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | Actions = [GetTextLayoutResult]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | |-Node #1000000004 at (l=0.0, t=0.0, r=0.0, b=0.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Role = 'Button'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: |-Node #10 at (l=427.0, t=985.0, r=654.0, b=1084.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Role = 'Button'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Actions = [OnClick]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | MergeDescendants = 'true'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | |-Node #11 at (l=471.0, t=1009.0, r=610.0, b=1061.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | Text = '[Cancel]'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | Actions = [GetTextLayoutResult]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | |-Node #1000000010 at (l=0.0, t=0.0, r=0.0, b=0.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Role = 'Button'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: |-Node #13 at (l=0.0, t=1128.0, r=1080.0, b=1386.0)px, Tag: 'MyStatusArea'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | |-Node #14 at (l=0.0, t=1128.0, r=540.0, b=1386.0)px, Tag: 'MyStatsNumberWithTitleBox'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | |-Node #15 at (l=254.0, t=1172.0, r=287.0, b=1246.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | | Text = '[4]'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | | Actions = [GetTextLayoutResult]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | |-Node #17 at (l=151.0, t=1290.0, r=389.0, b=1342.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | Text = '[Files checked]'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | Actions = [GetTextLayoutResult]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | |-Node #19 at (l=540.0, t=1128.0, r=1080.0, b=1386.0)px, Tag: 'MyStatsNumberWithTitleBox'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | |-Node #20 at (l=794.0, t=1172.0, r=827.0, b=1246.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | Text = '[0]'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | | Actions = [GetTextLayoutResult]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | |-Node #22 at (l=687.0, t=1290.0, r=933.0, b=1342.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Text = '[Apps checked]'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Actions = [GetTextLayoutResult]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: |-Node #24 at (l=0.0, t=1386.0, r=1080.0, b=1562.0)px, Tag: 'MyHistoryCard'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: Actions = [OnClick]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: MergeDescendants = 'true'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: |-Node #27 at (l=55.0, t=1430.0, r=143.0, b=1518.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | ContentDescription = '[]'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Role = 'Image'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: |-Node #28 at (l=198.0, t=1445.0, r=445.0, b=1504.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Text = ‘[My history]'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: | Actions = [GetTextLayoutResult]
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: |-Node #30 at (l=992.0, t=1455.0, r=1014.0, b=1494.0)px
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: ContentDescription = '[]'
10-16 19:04:10.055 1595 1730 D COMPOSE_LOG: Role = 'Image'