objective-cxcodexcode-ui-testingearlgrey

Can't scroll up using EarlGrey


I have a `UICollectionView', in which I'm able to scroll downward, but can't scroll upward. I'm not sure if I'm missing something very simple - Here's the code below:

(The formatting was weird, so here's a screenshot)

enter image description here

The first block executes perfectly, but the app won't scroll up again, and the button I need to tap remains offscreen.

Edit: Tried adding grey_sufficientlyVisible as per @gran_profaci, and still unable to find the element.

no UI element matching (matcherForSufficientlyVisible(>=0.750000) && (respondsToSelector(accessibilityIdentifier) && accessibilityID("bar"))) was found. But, it still exists in the logged hierarchy.

enter image description here


Solution

  • Here's a simple test that you could do with EarlGrey - set up a Table View or use EarlGrey's FunctionalTestApp and try scrolling to one content edge and then back. In the middle of one of the scrolls, pause the test and add the following to the debug console:

    po [GREYElementHierarchy hierarchyStringForAllUIWindows]
    

    What you might notice is that in the hierarchy, there might be a few cells that are not visible on the screen. When you used the scrolling search action to find grey_accessibilityID(@"bar"), you're searching to ensure only that the cell is present in the hierarchy and not if you can see / interact with it.

    Please add grey_sufficientlyVisible() to the grey_accessibilityID(@"...") matchers and see what you get.