【问题标题】:How to tell Detox to wait for my elements to appear如何告诉排毒等待我的元素出现
【发布时间】:2021-02-17 03:03:56
【问题描述】:

事件后我的视图需要一秒钟才能加载。 调用时:

expect(element(by.id('my-view'))).toBeVisible()

detox 有时会找到此元素,有时则不会。 如何让 detox 等待元素出现?

【问题讨论】:

  • 这里是在黑暗中拍摄,但是您是否在expect()...toBeVisible() 之前应用了await?

标签: react-native detox


【解决方案1】:

您可以使用 waitFor 函数和您定义的超时:

await waitFor(element(by.id('my-view'))).toBeVisible().withTimeout(5000)

这告诉 detox 在失败前等待 5000 毫秒。

在此处查看示例:https://github.com/wix/Detox/blob/master/docs/Troubleshooting.RunningTests.md#test-tries-to-find-my-component-before-its-created

【讨论】:

    猜你喜欢
    • 2010-11-08
    • 2017-02-04
    • 1970-01-01
    • 2020-07-29
    • 2022-01-02
    • 1970-01-01
    • 2016-05-09
    • 2013-01-12
    相关资源
    最近更新 更多