我在代码中为AVD设置了这些功能。
AND 6.0.0 API 23:
capabilities.SetCapability(AndroidMobileCapabilityType.Avd, “AND_6.0.0_1080x1920_4.95in”);
capabilities.SetCapability(MobileCapabilityType.PlatformName, “Android”);
capabilities.SetCapability(MobileCapabilityType.DeviceName, “AND_6.0.0_1080x1920_4.95in”);
capabilities.SetCapability(MobileCapabilityType.PlatformVersion, “6.0”);
capabilities.SetCapability(MobileCapabilityType.Language, Session.Language);
capabilities.SetCapability(MobileCapabilityType.Locale, Session.Locale);
capabilities.SetCapability(MobileCapabilityType.App, app);
AND 7.0.0 API 24:
capabilities.SetCapability(AndroidMobileCapabilityType.Avd, “AND_7.0.0_1080x1920_4.95in”);
capabilities.SetCapability(MobileCapabilityType.PlatformName, “Android”);
capabilities.SetCapability(MobileCapabilityType.DeviceName, “AND_7.0.0_1080x1920_4.95in”);
capabilities.SetCapability(MobileCapabilityType.PlatformVersion, “7.0”);
capabilities.SetCapability(MobileCapabilityType.Language, Session.Language);
capabilities.SetCapability(MobileCapabilityType.Locale, Session.Locale);
capabilities.SetCapability(MobileCapabilityType.App, app);
语言为“cs”或“en”,语言环境为“CZ”或“US”。
当我在AND 6.0.0上运行测试时,我可以在每次启动时更改语言,但在AND 7.0.0上,语言每次都设置为英语。
请问,哪里有问题?我想在AND 7.0.0上更改语言。我还有AND 5和4及其工作的功能,但在AND 7和8上它不起作用。
答案 0 :(得分:0)
您很可能遇到change locale on SDK 24+ with appium 1.7.2问题
作为解决方法,您有两个选择:
object AppInjector {
fun init(app: App) {
DaggerAppComponent.builder().application(app)
.build().inject(app)
app
.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
handleActivity(activity)
}
override fun onActivityStarted(activity: Activity) {
}
override fun onActivityResumed(activity: Activity) {
}
override fun onActivityPaused(activity: Activity) {
}
override fun onActivityStopped(activity: Activity) {
}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
}
override fun onActivityDestroyed(activity: Activity) {
}
})
}
private fun handleActivity(activity: Activity) {
if (activity is HasSupportFragmentInjector) {
AndroidInjection.inject(activity)
}
(activity as? FragmentActivity)?.supportFragmentManager?.registerFragmentLifecycleCallbacks(
object : FragmentManager.FragmentLifecycleCallbacks() {
override fun onFragmentCreated(fm: FragmentManager?, f: Fragment?,
savedInstanceState: Bundle?) {
if (f is Injectable) {
AndroidSupportInjection.inject(f)
}
}
}, true)
}
}
npm install -g appium@1.7.1
1.37.1中进行了修复,因此我的猜测肯定会在 1.7.3-beta 中。