量角器测试+管理执行顺序



我有一个量角器测试,看起来像

pageObject1.method1();
pageObject1.method2();
pageObject2.method1();
expect(pageObject2.method2());
let allDataList = pageObject2.method3();
expect(allDataList.includes('test1')).toBeTruthy();

如何确保对pageObject2.method3()的调用在下一次预期调用之前发生? method3()返回所有 span 元素的文本数组。

在这种情况下,您需要使用承诺

方式1:

await pageObject1.method2();
await pageObject2.method1();
expect(pageObject2.method2());
let allDataList = await pageObject2.method3();
expect(allDataList.includes('test1')).toBeTruthy();

说明 等待时

方式2:

pageObject1.method2().then(function() {
    pageObject2.method1().then(function() {
        expect(pageObject2.method2());
        pageObject2.method3().then(function(allDataList) {
            expect(allDataList.includes('test1')).toBeTruthy();
        });
    });
});

最新更新