Shorts. by Jeff Kreeftmeijer

iOS: Take screenshots without status bars with UIAutomation

I looked into automatically taking App Store screenshots this week.

To get the simplest thing that would work, I distilled the essential parts from ui-screen-shooter and ended up with a Ruby file that spawns simulators in different device languages and some javascript that uses UIAutomation to run through the application and take the actual screenshots.

Instead of just taking normal screenshots, it also takes care of removing the status bar, so the images can be dropped directly into iTunes Connect. It turned out that was quite simple to do with captureRectWithName():

target = UIATarget.localTarget()
rectWithoutStatusBar = target.rect()
rectWithoutStatusBar.origin.y = 20.0
target.captureRectWithName(rectWithoutStatusBar, 'home_without_status_bar')

Remember: To take 40 pixels off the top of the screenshot image to get the minimum screenshot size, you set the y-origin to 20.0 points.