Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 7 UI Testing target locale and region settings

I'm trying to set the language and the region of my UI Testing target, and unfortunately it doesn't seem to work.

I've tried both ways, first:

  • Product | Scheme | Edit Scheme
  • Run | Options
    • Application Language: French
    • Application Region: France
  • Test | Arguments
    • Use the Run action's arguments and environment variables: Checked

And I try this other way:

  • Product | Scheme | Edit Scheme
  • Test | Arguments
    • Use the Run action's arguments and environment variables: Unchecked
    • Arguments passed at launch:
      • -AppleLanguages (French)
      • -AppleLocale fr_FR

Each way resulting in the UI Testing still happening in English. Moreover, when I hit the record button, it runs in French...

So if I do something wrong, I would be happy to know!

Thanks in advance!

like image 582
Zaphod Avatar asked Mar 03 '16 15:03

Zaphod


Video Answer


2 Answers

I have figured it out. I set the locale settings in the launchArguments for testing temporary in Xcode.

override func setUp() {
    super.setUp()

    // Put setup code here. This method is called before the invocation of each test method in the class.

    // In UI tests it is usually best to stop immediately when a failure occurs.
    continueAfterFailure = false
    app = XCUIApplication()
    app.launchArguments = [
        "-inUITest",
        "-AppleLanguages",
        "(de)",
        "-AppleLocale",
        "de_DE"
    ]

For CI I use fastlane from Felix Krause and get localized screenshots with snapshot.

like image 137
ChaosSpeeder Avatar answered Oct 16 '22 12:10

ChaosSpeeder


Try changing the specs on the simulator. It worked for me every time.

On Simulator: Settings > General > Language & Region > iPhone Language --> change here

like image 30
Ricardo Alves Avatar answered Oct 16 '22 10:10

Ricardo Alves