Uiautomator cannot select or see the thumbnails in Gallery. So what you will have to do is determine the orientation of the device (portrait or landscape), then calculate the center coordinates of the thumbnail to be selected/tapped (for instance thumbnail 3 out of 7 thumbnails). Then tap or long-tap on the coordinates.
--