【发布时间】:2015-11-18 21:04:13
【问题描述】:
我正在尝试遍历元素列表以查找其中是否有任何一个具有特定值,因为它是 getText() 值。
我的问题是我的测试没有按照我设定的顺序执行。
我读过一堆关于排队和承诺解决的文章,但我不明白它如何影响我当前的场景。
这是我正在做的事情:
it('should find apps by name', function() {
var exists = false;
element.all(by.repeater(‘item in list’).each(function(elem) {
elem.getText().then(function(text) {
if(text == 'foo')
exists = true;
return exists;
}).then(function(exists) {
console.log('interim value: ' + exists); // This appears after
});
});
console.log('final status: ' + exists); // This appears in the console first
})
任何关于我如何确定我希望布尔值的值是什么的见解在我最后记录它之前将不胜感激。
【问题讨论】:
标签: javascript selenium promise protractor end-to-end