Hey, how am i supposed to do a scroll in a compose test where the view is a column with a scroll mod...
l
Hey, how am i supposed to do a scroll in a compose test where the view is a column with a scroll modifier ? I tried this but this didnt worked
Copy code
testRule.onNode(hasScrollToKeyAction()).performScrollToIndex(index)
a
Maybe using
hasScrollToIndexAction
instead of `hasScrollToKeyAction`*?* Or if that is what you're intending, then maybe using
performScrollToKey
instead of
performScrollToIndex
is what you need.
j
performScrollToKey
and
performScrollToIndex
are meant to be used on lazy lists, such as LazyColumn and LazyRow. They require that the content of the scrolling container respectively has keys and indices associated to them. In a plain column with a scrollable modifier, the content is just one big blob of content, and you'll have to use
performScrollTo
on the node you intend to bring into view:
Copy code
val matcher = /* matcher that matches the content you want to scroll to */
testRule.onNode(matcher).performScrollTo()
l
Thanks 🙏 very clear and helpful
2010 Views