Christophe Dongieux
10/24/2023, 8:11 AMcomposeTestRule
.onAllNodesWithContentDescription("Foobar")
.assertAreDisplayed() // <-- I want this kind of function
Any idea?Chrimaeon
10/24/2023, 11:33 AMChristophe Dongieux
10/24/2023, 11:42 AMcomposeTestRule
.onAllNodesWithContentDescription("Foobar")
.fetchSemanticsNodes()
But I get a List<SemanticsNode>
, I don't know what to do with that to call assertIsDisplayed()
b. SemanticsNodeInteractionCollection
by doing this
composeTestRule
.onAllNodesWithContentDescription("Foobar")
But there is nothing interesting I can do with SemanticsNodeInteractionCollection
if I don't expect any particular size.Chrimaeon
10/24/2023, 11:44 AMassertAll
that you can pass a matcher. Which in your case will be the isDisplayed
Christophe Dongieux
10/24/2023, 11:46 AMisDisplayed()
doesn't seem to existChrimaeon
10/24/2023, 11:49 AMChristophe Dongieux
10/24/2023, 11:51 AMChrimaeon
10/24/2023, 11:57 AMfetchSemanticNodes
which return the list of nodes that you can definitely assert with `isDisplayed`()Christophe Dongieux
10/24/2023, 11:58 AMprivate fun SemanticsNodeInteractionCollection.assertAreDisplayed(): SemanticsNodeInteractionCollection {
val semNodes = fetchSemanticsNodes()
semNodes.forEachIndexed { index, _ ->
val semanticsNodeInteraction = get(index)
semanticsNodeInteraction.assertIsDisplayed()
}
return this
}
It should work, I guessChrimaeon
10/24/2023, 11:59 AMChristophe Dongieux
10/24/2023, 11:59 AMSeveriano Jaramillo
10/24/2023, 6:57 PMserver-driven UI, anything is possible 🤷We use our own flavor of server-driven UI, but tests are still deterministic. The server responses are hardcoded and thus we know the number of elements that a particular test should have. Why is that not the case for you? Are you using a real server for your UI tests? Does your test involve testing for a random number of elements?
Christophe Dongieux
10/25/2023, 6:43 AM