Set the device language using automation

You can set the language of a mobile device either by using the Perfecto-specific deviceLanguage capability in your Appium script or by using the Perfecto extension perfecto:language:set. The capability method is preferred.

Supported language codes

You can use any of the following supported language codes:

ar-AE, zh-Hans-CN, en-US, fr-FR, fr-CA, de-DE, he-IL, it-IT, ja-JP, ko-KR, pt-BR, ru-RU, es-ES

Use the deviceLanguage capability

Using the deviceLanguage capability in your Appium test has the following advantages:

  • Does not require a reboot (because the session is created with the devices switched to the desired language)

  • Preserves the Appium session

  • Allows testing to begin immediately in the desired language

When using Appium 2 or Selenium 4 and later, which enforce the W3C WebDriver protocol, capabilities that extend standard Selenium or Appium functionality for use with Perfecto must include the perfecto: prefix to ensure proper processing by the Perfecto cloud.

Copy

Example (Java with Appium)

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "MyDevice");
capabilities.setCapability("perfecto:deviceLanguage", "fr-FR"); // Set device language to French (France)
capabilities.setCapability("app", "path/to/app.apk");

AndroidDriver driver = new AndroidDriver(new URL("http://your-cloud-url/wd/hub"), capabilities);

To learn more about available Appium capabilities, see Reference for capabilities in Perfecto.

Use the Perfecto extension perfecto:language:set

As an alternative, you can use the Perfecto extension perfecto:language:set to change the device language. This method is less preferred because it initiates a device reboot, which terminates the current Appium session.

To learn more about the Perfecto extension, see Set Device Language (FR).

To change the device language using the extension:

  1. Create a parameter map that includes the desired language code.

    For code samples, see Set Device Language (FR).

  2. Execute the perfecto:language:set script using your test automation framework.