Appium 用于 React Native 应用程序的 accessibilityLabel 的替代方案

Posted

技术标签:

【中文标题】Appium 用于 React Native 应用程序的 accessibilityLabel 的替代方案【英文标题】:Alternative of accessibilityLabel to be used by Appium for React Native apps 【发布时间】:2020-08-31 10:07:50 【问题描述】:

我们有多个 React Native 应用程序,我们正在使用 Appium web-driver 通过添加 accessibilityLabel 轻松识别元素,因此我使用该应用程序的语言环境并不重要,但现在我们收到了很多来自客户的抱怨ios系统正在使用accessibilityLabel来帮助残障用户。例如,Voice Over 使用此功能,如果您为此设置一些测试值,您的残障用户将受到影响。

我们也不能使用 byText 因为本地化的原因它不是最优的,现在我们的 React Native 开发团队要求我们为 accessibilityLabel 提供替代方案,有什么建议吗?

【问题讨论】:

【参考方案1】:

对于 React Native 中的 iOS,您可以使用 testID,而对于 android,据我所知,accessibilityLabel 是唯一的方法。 所以通常是这样的:

testID= "ElementId"
accessibilityLabel= "ElementTextDesc"

【讨论】:

在 Android 上使用 accessibilityLabel 而不是 testID 破解是不实际的,因为 react-native@0.65.x !!!查看更新日志:github.com/react-native-community/releases/blob/master/…;提交:github.com/facebook/react-native/commit/…;

以上是关于Appium 用于 React Native 应用程序的 accessibilityLabel 的替代方案的主要内容,如果未能解决你的问题,请参考以下文章

在 iOS 设备的 appium 中无法从 react-native 中找到内部 <Text> 标记/组件的 testID

需要一个测试框架来测试IOS Native + React本机App

react js web代码可以用于使用react native构建移动应用程序吗?

将下载的声音用于推送通知(react-native)

我可以将 react native 用于 android 电视应用程序吗?

用于 react-native 的 Code Push 打破玩笑测试