Appium Inspector无法在iOS元素层次结构中找到子元素

问题描述

基于构建的应用:React Native 0.62.2

用于测试的工具:Appium v​​1.17.1

问题描述:iOS层次结构中的子元素未由Appium Inspector检查/定位。

我们使用testID和accessibilityLabel属性为元素赋予ID:

返回{ testID:ID, accessibilityLabel:ID, };

但是,appium仍然无法识别iOS层次结构中的元素。

在Android元素层次结构中,我们看到元素“ ingredient_row_container_radish_wedges”的子元素

Android应用程序源:

enter image description here

但是在iOS上,我们看不到元素“ ingredient_row_container_radish_wedges”的子元素

iOS应用程序源:

enter image description here

解决方法

创建具有以下内容的课程:

import { Platform } from 'react-native';

export function accessibility(id?: string) {
  return Platform.OS === 'android'
    ? { accessible: true,accessibilityLabel: id }
    : { accessible: false,testID: id };
}

并在您想使用的位置导入“可访问性”功能 用作道具