有没有办法用量角器解决多个承诺? [英] Is there a way to resolve multiple promises with Protractor?
问题描述
我有这个:
element(by.id('x')).sendKeys('xxx').then(function(text) {
element(by.id('y')).sendKeys('yyy').then(function(text) {
element(by.id('z')).sendKeys('zzz').then(function(text) {
expect(element(by.id('myButton')).isEnabled()).toBe(true);
})
});
});
当元素x"、y"和z"都有值时,按钮myButton"被启用.我的理解是 sendKeys 返回一个承诺.
The button 'myButton' is enabled when the elements 'x', 'y' and 'z' all have values. It's my understanding that sendKeys returns a promise.
那么这是我可以检查是否启用了依赖于所有三个字段中的数据的myButton"的唯一方法?
So is this the only way that I can check if 'myButton' which depends on data in all the three fields is enabled?
推荐答案
你不需要链接任何 promise,因为量角器会等到所有语句都完成:https://github.com/angular/protractor/blob/master/docs/control-flow.md
You don't need to chain any promises because protractor will wait until all the statements are done: https://github.com/angular/protractor/blob/master/docs/control-flow.md
element(by.id('x')).sendKeys('xxx');
element(by.id('y')).sendKeys('yyy');
element(by.id('z')).sendKeys('zzz');
expect(element(by.id('myButton'));
如果您想解决多个承诺,请使用:
If you want to resolve multiple promises use:
var webdriver = require('selenium-webdriver');
webdriver.promise.fullyResolved(promises);
例如:https://github.com/angular/protractor/blob/d15d35a82a5a2/lib/protractor.js#L327
这篇关于有没有办法用量角器解决多个承诺?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!