[英]Element.getAttribute() returning promisestatus as Pending : protractor
My Statement我的声明
var data = elmnt.getAttribute('row-id').then(function(value){
rowid = value
callback();
});
console.log('global var inside Rowid:'+ rowid);
console.log('global var inside data:'+ data);
My Output :我的 Output :
global var inside Rowid:null global var inside data:ManagedPromise::19682 {[[PromiseStatus]]: "pending"}
Rowid 内的全局变量:null 数据内的全局变量:ManagedPromise::19682 {[[PromiseStatus]]: "pending"}
can someone please help有人可以帮忙吗
Ah, sorry, didn't notice the protractor
tag.啊,抱歉,没有注意到
protractor
标签。
So, if we have a promisified getAttribute
, then that's how you consume promises:所以,如果我们有一个承诺的
getAttribute
,那么这就是你使用承诺的方式:
elmnt.getAttribute('row-id').then(function(rowId) {
console.log(rowId);
});
You need to do it inside the promise chain.您需要在 promise 链中执行此操作。
console.log(somePromise)
will only log a promise, not a value, and console.log(rowid)
before the promise is resolved will produce null
/ undefined
. console.log(somePromise)
只会记录一个 promise,而不是一个值, console.log(rowid)
在 promise 被解析之前会产生null
/ undefined
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.