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

时间:2019-05-27 08:32:20

标签: promise protractor

我有一个类似

的量角器测试
pageObject1.method1();
pageObject1.method2();
pageObject2.method1();
expect(pageObject2.method2());
let allDataList = pageObject2.method3();
expect(allDataList.includes('test1')).toBeTruthy();

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

1 个答案:

答案 0 :(得分:0)

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

方法1:

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

Description On await

方法2:

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