【发布时间】: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