Change MacOs App language using XCUITest

I am trying to change the Mac OS Apps to a new locale other than English using the following arguments in XCUITest:

app.launchArguments = [
 "-inUITest",
 "-AppleLanguages",
 "(nl)",
 "-AppleLocale",
 "nl_NL"
]

But I get the following message on the console:

Launching macOS application via NSWorkspace while sandboxed. Launch arguments and environment variables may be dropped

The app loads in English itself.

Is there any other way I can change the language of such apps ?

I DONT mind changing the system language as well, but it needs to be done programatically. I tried writing a zsh script to do sudo languagesetup but it requires a restart for the system language to change, which I can't do when my automation is running. If there is any other way please let me know.

EDIT: I open a third party app using the bundle Identifier, like this:

 XCUIApplication(bundleIdentifier: "<app-bundle-name>")

Replies

When writing a test, you should use a test plan, which have configurations for the application language and region when testing.

  • @edford, are you saying that changing the language on the fly by using launchArguments doesn't work, and is the intended behaviour? It seems the app's language doesn't change in iOS tests either, but there's no message on the console.

Add a Comment