Search code examples
iosswiftxctestxcode-ui-testing

Unable to access cells from CollectionView element in UITest


I am trying to access cells from CollectionView element in UITest. Unlike tableview I could be able to get cells only that are visible even if I scrolled to the end of the collection view. Just I want to know is it possible in any way to access all cells from collectionview like we access from tableview element.

Actually my requirement is to check the number of cells should be displayed less than 10 even if the mocked response has more.

I have put additional effort to understand more about collection view and its caching strategy. However there are lot of experts here could answer in simple way in no time. Hence I am posting this. Your answer may help to someone like me who struggles to access the cells from collectionview.

Thanks in advance.

Note: I have mock server implementation.


Solution

  • CollectionView does not expose off-screen subviews – probably to improve performance.