【问题标题】:React Native: How to navigate from one screen to another in Detox testsReact Native:如何在排毒测试中从一个屏幕导航到另一个屏幕
【发布时间】:2020-12-23 00:03:59
【问题描述】:

我正在尝试使用 Detox 为我的应用程序编写测试。但是在从登录屏幕导航屏幕时,由于找不到匹配器,我的测试失败了。 我在渲染函数中正确添加了 testID 仍然出现错误。 这是我的测试代码:

it('should login successfully', async () => {
await device.reloadReactNative();

await element(by.id('textInput_username_login')).typeText('test');
await element(by.id('textInput_password_login')).typeText('123456');
await element(by.text('Log In')).tap();
await expect(element(by.id('otp'))).toBeVisible();
});

出现以下错误:

Test Failed: No elements found for “MATCHER(identifier == “ otp” && NOT DESCENDANT(class ⊇ “RCTTextView” && identifier == “ otp”))”

提前致谢。

【问题讨论】:

    标签: ios react-native e2e-testing detox


    【解决方案1】:

    另一种选择是使用 Flutter 的布局检查器来查找元素并验证它是否具有与“otp”匹配的测试 id:https://fbflipper.com。您可以将其作为桌面应用程序下载,但 Mac 会抱怨,因为它不是来自 App Store,只是提醒一下。

    【讨论】:

      【解决方案2】:

      不能正确添加 testID。如果您在 iOS 上运行,您可以添加 --loglevel 详细参数并查看打印的层次结构以查找您希望看到的元素并检查 id 是否在其上或是否在屏幕上。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-01-22
        • 1970-01-01
        • 1970-01-01
        • 2017-11-22
        • 2010-11-09
        • 2021-01-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多