We are trying to get a UIAutomation test around a flow in our app where a user selects an image from a UIImagePickerController. All the automation works great, until we try to select an image from the picker controller. It seems like we cannot get the right object to send the tap to. Here is what we are trying:
UIALogger.logMessage("Navigation Title: " + app.navigationTitle() );
window.collectionViews()[0].tapWithOptions({tapOffset:{x:0.5, y:0.5}});
The above will show the navigation title as "Moments", which means we are in the photo picker, but the second line gets no error - but does not select anything (no matter the coordinates).
The test ultimately fails being stuck on the photo selection screen.
I logged the element tree below, and you can see that it appears that there is a UICollectionView out there, but all the cells are the section headers and there are none in the debug log output that are actual 'photos'.
So how do we select an image from a UIImagePickerController with UIAutomation?
Thanks!
So, I figured this out. Duh. I just needed to access the visible cells and send the tap to one of those. Works like a charm.
window.collectionViews()[0].visibleCells()[0].tap();
I hope this helps someone else!