nightwatch version: 1.3.5
I write a commond in PageObject and return a Promise,when I use it like "await xxx",I got some errors.
But I actually return a Promise...
The commond in PageObject:
waitForAllElementNotPresent(selector = '.el-loading-mask', time = 10000) {
const _that = this;
return new Promise(function (resolve, reject) {
_that.api.elements('css selector', selector, function (res) {
let len = res.value.length;
let times = 0;
for (let i = 0; i < len; i++) {
_that.api.waitForElementNotPresent('css selector', {
selector: selector,
index: i
}, time, function () {
times++;
});
}
let timeInterval = setInterval(() => {
if (times >= len) {
resolve();
clearInterval(timeInterval);
}
}, 500);
});
});
}
used the commond like this:
await this.topNav.waitForAllElementNotPresent('.el-loading-mask');
the error like this:
- writing an ES6 async test case? - keep in mind that commands return a Promise;
- writing unit tests? - make sure to specify "unit_tests_mode=true" in your config.
Aucun commentaire:
Enregistrer un commentaire