I'm using react-virtualized for a lengthy (1000+) list of items to select from. And I'm trying to set up an end to end test that requires clicking on one of the elements that are not currently rendered.
Ordinarily, I'd simply use something like:
await t.click(
ReactSelector('ListPage')
.findReact('ListItem')
.nth(873) // or .withText(...) or .withProps(...)
)
But because only a small subset of the ListItem
s are rendered, TestCafe fails to find the desired element.
I've been trying to figure out how to use TestCafe's ClientFunction to scroll the list container so the desired ListItem
is rendered.
However, I'm running into a few issues:
- Is there a way to share a
Selector
into theClientFunction
and modify the DOM element's scrollTop? Or do I have to re-query the element via the DOM directly? - Due to the
ListItem
s being different heights, the scroll position is not a simple calculation of index x item height. How can I keep updating/scrolling within this function until the desiredSelector
is visible?