我有一个示例组件代码:
import { Button } from 'react-native-elements'
...
...
render() {
return(
<View>
<Button testID='testButton' ... />
</View>
)
}
测试文件示例:
await element(by.id('testButton')).tap()
对于普通按钮,测试工作正常。对于第三方按钮,我仅使用react-native-elements
,测试失败并显示:
Error: Error performing 'single click' on view '(with tag value: is "testButton" and view has effective visibility=VISIBLE)'.
我尝试匹配按钮的文本,但它也失败并显示(Add Product
是按钮的标题/文本):
Error: Error performing 'single click' on view '(with text: is "Add Product" and the view has effective visibility=VISIBLE)'.
自从本机按钮通过以来,我了解到第三方组件需要做一些不同的事情。我有自己的自定义组件,并且通过将testID
深入发送到react-native
组件来处理这些组件,并且它们可以工作。我不知道如何使用第三方组件解决这种情况。
我正在Android上运行它