Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS UI Automation for different languages

my iOS application has localization for 10+ languages. I'd like to check that all screens looks ok (labels aren't too long/short etc).

I know I can go through my app and make screenshots using UI Automation. Is there any way do switch simulator's language in UI Automation? Is there any way to generate screenshots for my app just by launching 1 command?

Thanks!

like image 986
OgreSwamp Avatar asked Nov 13 '12 16:11

OgreSwamp


People also ask

How iOS determines the language for your app?

Q: How does iOS determine the language for my app? A: To determine the language for your app, iOS considers not only the order of the user language preferences (in General > Language & Region of the Settings application) but also the localizations your app declares it supports.

Can Swift be used for automation?

Swift is a great programming language to automate small tasks in your daily workflow on macOS. Raycast puts these scripts at your fingertips and you execute them from anywhere on your desktop. You can take it one step further, and assign a global hotkey to your script command.

How many languages does iOS support?

There Are Two Main Languages That Power iOS: Objective-C and Swift. You can use other languages to code iOS apps, but they may require significant workarounds that require more effort than needed.

What is UI Automation in iOS?

UI Automation is a tool that Apple provides and maintains for higher level, automated, testing of iOS applications. Tests are written in JavaScript, adhering to an API defined by Apple. Writing tests can be made easier by relying on accessibility labels for user interface elements in your application.


2 Answers

Yes there is. I just wrote it myself as a matter of fact. :)

Use this project: https://github.com/jonathanpenn/ui-screen-shooter

It's a demonstration of how to run UI Automation from the command line, swap simulator languages with a plist changing command, and choose simulator device types with an AppleScript. It's documented heavily with comments, but if you're confused about something, feel free to open an issue or a pull request on the project and we can improve it.

like image 140
Jonathan Penn Avatar answered Sep 19 '22 15:09

Jonathan Penn


There is another github project called Snapshot, for exactly what you want.

It provides the same (and more) features that UI Screen Shooter has, and I found it to be a bit more fleshed out and documented.

The most challenging part of getting up and running is learning the Javascript API for performing actions in the simulator, but you can find many useful tutorials for that online.

Here are some useful references:

  • UIAutomation Testing Tutorial
  • Apple's UIAutomation Guide
  • API Reference for UIAutomation objects
  • Random snippets from Apple
like image 43
Matt Mc Avatar answered Sep 21 '22 15:09

Matt Mc