Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Xcode7's UI tests to create app screenshots for the App Store

Every time we change something in the UI, we have to manually prepare and take 375 (= 5 screenshots * 5 device types * 15 languages) screenshots for iTunes Connect's listing.

I'm trying to "exploit" iOS 9's new UI testing to automatically prepare and take these screenshots for each language. This should save a huge amount of time and provide a better experience to our users, because we didn't update the screenshots frequently due to the hard work involved.

I couldn't find much help on the internet, probably because this feature is too fresh. So here are two essential questions, hopefully we can find a way to make it happen.

  1. Is it possible to save a screenshot to disk through the UI testing API?

  2. Is it possible to have a clean install for a XCTestCase?

like image 443
Kof Avatar asked Jun 18 '15 06:06

Kof


2 Answers

This isn't completely related to Xcode 7, but you can automate screenshot taking with snapshot.

like image 77
rounak Avatar answered Oct 02 '22 12:10

rounak


Yes, you can create screenshots using the Xcode UI Testing.

  • Create a custom scheme for your tests (optional but recommended).
  • Use CLI(terminal) to run the tests. Something like this:
xcodebuild -workspace App.xcworkspace \
     -scheme "SchemeName" \
           -sdk iphonesimulator \
           -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.0' 
           test

Once you are done with this, to generate screenshots, add the path to where you want the screenshots, like this:

xcodebuild -workspace App.xcworkspace \
 -scheme "SchemeName" \
       -sdk iphonesimulator \
       -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.0'
       -derivedDataPath './output'
       test

./output will tell Xcode to take screenshots for every test. You can find this in detail here

like image 26
Gautam Jain Avatar answered Oct 02 '22 14:10

Gautam Jain