【发布时间】:2019-05-27 23:16:26
【问题描述】:
我有一个量角器测试,看起来像
pageObject1.method1();
pageObject1.method2();
pageObject2.method1();
expect(pageObject2.method2());
let allDataList = pageObject2.method3();
expect(allDataList.includes('test1')).toBeTruthy();
如何确保对pageObject2.method3() 的调用发生在下一个期望调用之前? method3() 返回所有 span 元素的文本数组。
【问题讨论】:
-
您在 method3() 中使用 async 和 await 吗?请分享method3模板
-
方法3
getCurrDataAcsGrps(): Array<string>{ let allGroupsList = new Array(); this.currAcsGrpList.each(function(element,index){ element.getText().then(function(text) { //console.log(index, text); allGroupsList.push(text); }); }); return allGroupsList; } -
method3 - 将所有 span 元素的值放入数组中
-
试过 async/await 但它给出了不同的错误
-
async getCurrDataAcsGrps(): Array
{ let allGroupsList = new Array(); await this.currAcsGrpList.each( async=> (element,index){ await element.getText().then(async=> (text) { //console.log(index, text); await allGroupsList.push(text) ; }); });返回所有组列表; }
标签: promise protractor