Elias Nogueira
2 min readJun 14, 2016

Appium Tips — Changing the app Language

Introduction

When an mobile app has a multiple languages, obviously, it's necessary to validate the translations and check if the labels, buttons, components in general will display correctly the texts.
Do this job in a manual way is tedious and error prone and the big problem: take along time.

Example

There's an app in English (en-US) and Brazilian Portuguese (pt-BR) with a simple login screen. We'll focus on four items on screen:

Translation table
App in en (left) and pt_BR (right)

How to execute test changing the language?

It'’ really simple. Appium has a capability on the server side called language.

DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability("language", "pt");

Thought the DesiredCapabilities class we need to inform the language capability (setCapability) as Portuguese. To put another language just use the ISO 639–1 language. But remember one thing: the app will switch to another language if is supported in the android code (e.g: if you switch to fr and Franch is not supported in the app, the default language will displayed).

You also can se the supported language codes in Android here http://www.apps4android.org/?p=3695

How appium does that?

Appium restart your emulator/device changing the entire language wthout affect the running test. It's like a pre-condition.

Take a look at this picture: http://imgur.com/ds9ijTo

A thing to remember…
You need to pass the language capability before the driver instance. This guarantee the language change from the first test. Remember that Appium "restart" the device with de new language.

Sample code