How to changing app language


#1

I’m creating a series of Appium tips… useful code snippets to do some “unusual” in our day…
Here is the first one…

Regards!


#2

@Elias_Nogueira thanks for posting that. It’s yet another useful tool to perform testing. Since we didn’t know about this, our solution was to start android settings and change the language that way, which is only really possible if you allow yourself access to adb to start the correct settings screen.

One of the challenges when testing in multiple languages is when there is no way to identify an element other than through the text. Since we can’t embed every version of a character string in the test code, we use the strings.xml file from the apk under test. We unpack the apk using apktool, then parse all the strings.xml file, using the symbol as the key to find the appropriate string in the language we are testing.


#3

obj.setCapability(“LOCALE”, “FR”);
obj.setCapability(“LANGUAGE”,“fr”);

I pass ed these desired capabilities. But when the script runs, ithe app opens up in English languagae only.
Any leads?


#4

Check device language. Does it gets changed to FR and only your app doesn’t or nothing changes to FR?

There is a line in logs with the information of locale/language being set. Can you share your logs


#5

[debug] [MJSONWP] Calling AppiumDriver.getSession() with args: [“5765ceff-77c5-48d5-a975-e93c2d5b1c07”]
[debug] [MJSONWP] Responding to client with driver.getSession() result: {“platform”:“LINUX”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“LANGUAGE”:“fr”,“LOCALE”:“FR”,“appActivity”:“net.ilius.android.app.screen.activities.StarterActivity”,“appPackage”:“net.ilius.android.meetic”,“deviceName”:“S7”,“platformName”:“android”,“resetKeyboard”:false,“unicodeKeyboard”:true},“LANGUAGE”:“fr”,“LOCALE”:“FR”,“appActivity”:“net.ilius.android.app.screen.activities.StarterActivity”,“appPackage”:“net.ilius.android.meetic”,“deviceName”:“emulator-5554”,“platformName”:“android”,“resetKeyboard”:false,“unicodeKeyboard”:true,“deviceUDID”:“emulator-5554”,“platformVersion”:“7.0”,“deviceScreenSize”:“1440x2560”,“deviceModel”:“Android SDK built for x86”,“deviceManufacturer”:“Google”}
[HTTP] <-- GET /wd/hub/session/5765ceff-77c5-48d5-a975-e93c2d5b1c07 200 18 ms - 906


#6

The device langugae remained the same(English). Nothing changes to FR


#7

And when i use,

> obj.setCapability("language", "fr"); , I get the following logs

[debug] [AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.
[MJSONWP] Encountered internal error running command: Error: Failed to set language: fr and country: null
at Object.callee$0$0$ (C:\Users\s.sebastine\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:101:11)
at tryCatch (C:\Users\s.sebastine\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\s.sebastine\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\s.sebastine\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (C:\Users\s.sebastine\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at
[HTTP] <-- POST /wd/hub/session 500 1318 ms - 181


#8

Have you tried with latest appium beta?

Take a look in here: