我有个量角器测试,看起来像是
pageObject1.method1();
pageObject1.method2();
pageObject2.method1();
expect(pageObject2.method2());
let allDataList = pageObject2.method3();
expect(allDataList.includes('test1')).toBeTruthy();如何确保在下一次expect调用之前调用pageObject2.method3()?method3()返回一个包含所有span元素的文本的数组。
发布于 2019-05-27 16:52:28
在这种情况下,您需要使用promises
方式-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();
});
});
});https://stackoverflow.com/questions/56322390
复制相似问题