Option 1: Set a Default Language
Create a new scheme for UI Testing and set the default Application Language. This will lock the app into one localized file so you can write all of your tests for that language.
Set the option from Product -> Scheme -> Manage Schemes or ⌘⇧,. Then select the Options tab and set the language.
Pros: Simple, one-time change.
Cons: Cannot be used to create localized screenshots with snapshot (a tool that runs your app via UI Testing and generates App Store screenshots along the way).
Option 2: Use -accessibilityIdentifier
for Localized Strings
Instead of accessing items via their displayed text or value, use accessibilityIdentifier
. This is read by the UI Testing framework but never shown or read to users (even with accessibility turned on). In the old UIAutomation docs Apple mentions using this for developer functionality, which this seams like a good use case.
You can then continue to set accessibilityLabel
and accessibilityValue
like normal, with the localized versions.
Pros: Can be used for more generic solutions, such as taking automated screenshots.
Cons: Might require more work changing each label you need "unlocalized" for testing.
localizable.strings
! However, I cannot seem to get it to work with my Storyboard string files. Do you have any idea how I can fix that? Doesn't the storyboard strings go to the eventual lproj folder when building? – Prehensile