From 94afb69cbd0288da642d0974fc90602d8657535b Mon Sep 17 00:00:00 2001 From: mwakizaka <21286384+mwakizaka@users.noreply.github.com> Date: Sun, 26 Nov 2023 16:08:49 +0900 Subject: [PATCH] fix: avoid WDA shutdown when running mobile: configureLocalization script ref: https://github.com/appium/appium/issues/19440#issuecomment-1823461012 --- docs/execute-methods.md | 3 ++- lib/commands/localization.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/execute-methods.md b/docs/execute-methods.md index a614c38484..f82cbff5db 100644 --- a/docs/execute-methods.md +++ b/docs/execute-methods.md @@ -676,8 +676,9 @@ remotePath | string | yes | Same value as for `mobile: deleteFile` except of the Change localization settings on the currently booted Simulator. The changed settings are only applied for the *newly started* applications/activities. Currently running applications will stay unchanged. This means, for example, that the keyboard -should be hidden and shown again in order to observe the changed layout, and curresponding +should be hidden and shown again in order to observe the changed layout, and corresponding apps must be restarted in order to observe their interface using the newly set locale/language. +Also this method might leave some system UI alerts untranslated. Be careful while setting the actual arguments since their actual values are not strictly checked. This could lead to an unexpected behavior if an incorrect/unsupported language or locale abbreviation is provided. diff --git a/lib/commands/localization.js b/lib/commands/localization.js index c3dca59435..b43cd072c5 100644 --- a/lib/commands/localization.js +++ b/lib/commands/localization.js @@ -22,9 +22,14 @@ export default { async mobileConfigureLocalization(keyboard, language, locale) { assertSimulator(this); + // Assign skipSyncUiDialogTranslation: true option in order to avoid shutting down the WDA session + const localizationOptions = { + language: language ? Object.assign(language, {skipSyncUiDialogTranslation: true}) : {}, + locale, keyboard + }; return /** @type {boolean} */ ( // @ts-expect-error - do not assign arbitrary properties to `this.opts` - await this.opts.device.configureLocalization({language, locale, keyboard}) + await this.opts.device.configureLocalization(localizationOptions) ); }, };