Skip to content
New issue

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

Failed to perform isDisplayed check #14

Closed
braindonor opened this issue Oct 16, 2021 · 3 comments
Closed

Failed to perform isDisplayed check #14

braindonor opened this issue Oct 16, 2021 · 3 comments

Comments

@braindonor
Copy link

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'

@FrangSierra
Copy link

Hello!

I have been running this issue aswell during the past days. It has something to do with the useUnmergedTree parameter that the onRoot should be able to receive. However the onRoot().onChildren() method doesn't take into account the nested children of the node no matter if you make use of useUnmergedTree or not.

I have opened a PR (#15) with a fix for it. Please take a look at it!
Thank you so much.

@braindonor
Copy link
Author

Hi @FrangSierra , I downloaded your branch and tested it against my project and it works great. I can't really comment on whether this is the best way to solve the problem as I'm not very familiar with the workings of compose.

Many thanks,

Pentti

@Vacxe Vacxe added this to the 0.0.2 milestone Oct 19, 2021
@Vacxe
Copy link
Member

Vacxe commented Oct 24, 2021

Close with #17

@Vacxe Vacxe closed this as completed Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants