Appium 求教:Appium DesiredCapabilities 设置语言和 地区,执行程序报错:Original error: Failed to set language: fr and country: undefined

louie · 2020年08月28日 · 最后由 louie 回复于 2020年08月31日 · 2292 次阅读

需求
测试国际化,执行自动化测试脚本前,需要设置语言

现状
按照官方文档,设置了语言,执行程序报错

报错信息
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Failed to set language: fr and country: undefined
at getResponseForW3CError (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:826:9)
at asyncHandler (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:447:37)
at process._tickCallback (internal/process/next_tick.js:68:7)

官网文档

程序

共收到 4 条回复 时间 点赞

我猜:

  1. country 应该是对应 locale? 参数名字确认一下是不是对的。
  2. 你的设备是 Android 6.0 吗?感觉会不会是这两个参数还不支持那个版本。现在主流的安卓机都是 9.0 以上了,建议换高点版本的模拟器或者手机来试下吧
5楼 已删除
Jerry li 回复

country 是看报错信息修改的,重新改回 locale 试了一下,还是不行
模拟器试了 6.0、7.0、8.0、9.0 ,Appium-client 也调试 1.X 、5.X、6.X、7.X
以前设置过 web 国际化,但移动端的国际化没涉及。看了官网有这个配置,试了一下,还是不行😂 ,龙哥做过移动端国际化吗?

web 例子
options = webdriver.ChromeOptions()
# 设置启动语言
options.add_argument('lang=en_US.UTF-8')

louie 回复

😂我们没有涉及到怎么设置手机的语言
刚刚查了一下,appium 对这两个字段的设置好像支持不是很好,GitHub 上面也好多 issue

已解决,采用笨方法模拟用户操作。 😂
解决方案:先启动 settings 页面,修改好语言,再跳回被测应用程序

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册