【问题标题】:Detox: "Cannot find UI element." when trying to scroll FlatList排毒:“找不到 UI 元素。”尝试滚动 FlatList 时
【发布时间】:2019-07-19 00:41:34
【问题描述】:

这是测试代码:


//navigates to the new screen:
  it("should show myFlatListScreen after tap", async () => {
    await element(by.id("navigationButton")).tap();
    await waitFor(element(by.id("myFlatListScreen"))).toBeVisible();
  });

//Passes without issue:
  it("FlatList should be visible", async () => {
    await waitFor(element(by.id("myFlatList"))).toBeVisible();
  });

//Fails with: "Cannot find UI element." error
  it("FlatList should scroll", async () => {
    await element(by.id('myFlatList')).scroll(100, 'down');
  });

为什么元素可以通过toBeVisible() 测试,然后不存在滚动?

编辑:我想通了。在这些之前有一些代码如下所示:

  beforeEach(async () => {
    await device.reloadReactNative();
  });

应用程序每次都从头开始重新加载,这就是该元素不再可用的原因。看来我必须编写所有测试,以便它们从头到尾运行。

【问题讨论】:

    标签: react-native e2e-testing detox


    【解决方案1】:

    在这些之前有一些代码如下所示:

    beforeEach(async () => {
      await device.reloadReactNative();
    });
    

    应用程序每次都从头开始重新加载,这就是该元素不再可用的原因。看来我必须编写所有测试,以便它们从头到尾运行。

    【讨论】:

      猜你喜欢
      • 2020-11-04
      • 2021-09-09
      • 1970-01-01
      • 2019-08-26
      • 1970-01-01
      • 2019-10-30
      • 2020-10-01
      • 2018-05-23
      • 2018-08-26
      相关资源
      最近更新 更多