Appium Inspector无法在iOS元素层次结构中找到子元素 [英] Appium Inspector is unable to locate the child elements in iOS Element Hierarchy
问题描述
基于以下应用构建的应用:React Native 0.62.2
Apps built on : React Native 0.62.2
用于测试的工具:Appium v1.17.1
Tool used for Testing : Appium v1.17.1
问题描述:Appium Inspector不会检查/定位iOS层次结构中的子元素.
Issue Description : The Child Elements in the iOS hierarchy are not getting inspected/located by Appium Inspector.
我们使用testID和accessibilityLabel属性为元素赋予ID:
We are giving IDs to elements using testID and accessibilityLabel properties :
返回{testID:ID,accessibilityLabel:ID,};
return { testID: id, accessibilityLabel: id, };
但是,appium仍然无法识别iOS层次结构中的元素.
But still the appium is not able to identify the elements in the iOS hierarchy.
在Android元素层次结构中,我们看到元素"ingredient_row_container_radish_wedges"的子元素
On Android Element Hierarchy we see the Child elements of the element "ingredient_row_container_radish_wedges"
Android应用程序源:
Android App Source :
但是在iOS上,我们看不到元素"ingredient_row_container_radish_wedges"的子元素
But on iOS we don’t see the child elements of the element "ingredient_row_container_radish_wedges"
iOS应用程序源:
iOS App Source :
推荐答案
创建一个包含以下内容的类:
create a class with following content:
import { Platform } from 'react-native';
export function accessibility(id?: string) {
return Platform.OS === 'android'
? { accessible: true, accessibilityLabel: id }
: { accessible: false, testID: id };
}
并在您想使用的位置导入可访问性"功能用作道具
and import 'accessibility' function where you want to use then use it as props
<查看{... accessibility('ingredient_row_container_radish_wedges')}>
<View {... accessibility('ingredient_row_container_radish_wedges')}>
这篇关于Appium Inspector无法在iOS元素层次结构中找到子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!