如果之前有人问过这个问题,请提前道歉。我遇到了detox
用于响应本机应用程序的 e2e 框架,我想尝试一下。
我正在尝试自动化这里给出的这个演示移动应用程序 -链接
由于测试detox
用作testID
定位器之一,所以我在LoginScreenMaterial.js
里面的文件中添加了一个,app/screen/LoginScreenMaterial.js
如下所示
<View testID="login_screen" style={{width: this._width, justifyContent: 'center'}}>
<RkCard style={styles.container}>
<View rkCardHeader style={styles.header}>
<RkText/>
<RkText style={styles.label}>Sign in into your account</RkText>
</View>
然而,即使在成功构建应用程序之后,我还是通过这个简单的测试运行了应用程序
it('should have welcome screen', async () => {
await expect(element(by.id('login_screen'))).toBeVisible();
});
但是,由于无法识别元素,测试仍然失败。我在这个测试中缺少什么?我们不能在文件中testID
明确添加这样的内容吗?.js
编辑 1:添加错误消息
1) Example
should have welcome screen:
Error: Error: Cannot find UI Element.
Exception with Assertion: {
"Assertion Criteria" : "assertWithMatcher:matcherForSufficientlyVisible(>=0.750000)",
"Element Matcher" : "(((respondsToSelector(accessibilityIdentifier) && accessibilityID('login_screen')) && !(kindOfClass('RCTScrollView'))) || (kindOfClass('UIScrollView') && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(((respondsToSelector(accessibilityIdentifier) && accessibilityID('login_screen')) && kindOfClass('RCTScrollView'))))))",
"Recovery Suggestion" : "Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element."
}
Error Trace: [
{
"Description" : "Interaction cannot continue because the desired element was not found.",
"Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
"Error Code" : "0",
"File Name" : "GREYElementInteraction.m",
"Function Name" : "-[GREYElementInteraction matchedElementsWithTimeout:error:]",
"Line" : "124"
}
]
at Client.execute (node_modules/detox/src/client/Client.js:74:13)