Reputation: 153
I have a navigator structure like so:
stack
drawer
stack
tab
My hierarchy from there is:
view
view
flatlist
I'm trying to get my flatlist to scroll downward. You can see the finger animation but the list isn't moving. You can see it in this gif:
Screen Recording 2018-03-16 at 11.30 p.m..gifHere's my code:
it('should have infinite scrolling', async () => {
await expect(element(by.id('NewsFeed.Scroller'))).toBeVisible();
await expect(element(by.id('NewsFeedScreen.ArticleListing-0'))).toExist();
await expect(element(by.id('NewsFeedScreen.ArticleListing-10'))).toNotExist();
await element(by.id('NewsFeed.Scroller')).scroll(10000, 'down');
await expect(element(by.id('NewsFeedScreen.ArticleListing-10'))).toExist();
});
I believe the issue is that scroll action begins at the bottom of my screen. When I attempt to start a scroll form there myself it does not work either. I'm not seeing anything in the API to allow me to put an offset on where that gesture begins. Looking that element in the inspect reveals that its not in the area which Detox begins its gesture: https://d3vv6lp55qjaqc.cloudfront.net/items/323C3D3U3y1Y2Z1B2L2J/Screen%20Shot%202018-03-16%20at%2023.47.48.png?X-CloudApp-Visitor-Id=2852073&v=31521c3c
Upvotes: 3
Views: 4000
Reputation: 13
If anyone faces this issue now -- try using the startPositionX
or startPositionY
parameters of the .scroll()
method, e.g:
await element(by.id('scrollView')).scroll(200, 'down', NaN, 0.5)
Worked like a charm for me, when I faced the same problem.
Upvotes: 1
Reputation: 153
I've found a solution which is good enough while we wait for https://github.com/wix/detox/issues/589 to be resolved.
await element(by.id('NewsFeedScreen.ArticleListing-0')).swipe('up', 'fast', 0.9);
Results in the behaviour I'm looking for, scrolling down in my list
Upvotes: 10