我正在尝试将UI测试集成到一个相当大的react原生项目中。但是,一旦我想要记录ui测试,我就会收到警告
Timestamped Event Matching Error: Failed to find matching element
这是我正在点击的ui元素。
<TouchableOpacity style={containerStyle}
onPress={this.props.onPress}
accessibilityLabel='back_button_touchable'
accessible={true}
testID='back_button_touchable'
underlayColor='#99d9f4'>
<Image style={iconStyle} source={require('../white-arrow.png')}/>
<Text style={styles.text}>{this.props.text}</Text>
</TouchableOpacity>我刚刚设置了一个全新的react原生项目,并试图让ui测试运行起来,一切都很好。因此,这就引出了一个问题,即现有代码/构建设置以某种方式阻止了元素检索。
有什么想法可以禁用或阻止ui测试吗?
发布于 2018-09-18 20:32:32
对于其他正在寻找答案的人来说,我发现RN中的可触摸元素在UI测试方面存在问题。
如果您在可触摸对象上设置了accessible={false},则在录制时,testID将作用于Text & View子元素。
<TouchableOpacity onPress={onPressFn} accessible={false}>
<View style={styles.buttonContainer} testID="button">
<Text style={styles.buttonText}>
{children}
</Text>
</View>
</TouchableOpacity>https://stackoverflow.com/questions/50564829
复制相似问题