简体   繁体   English

Element.getAttribute() 将 promisestatus 返回为待处理:protractor

[英]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.

相关问题 量角器 - 如果element.getAttribute('class')发生更改,则退出嵌套for循环 - Protractor - exiting nested for loop if element.getAttribute('class') changes element.getAttribute 不是函数 - element.getAttribute is not a function 完美滚动条:element.getAttribute不是函数 - Perfect-scrollbar: element.getAttribute is not a function Internet Explorer 7 element.getAttribute 方法中的错误 - Bug in Internet Explorer 7 element.getAttribute method 为什么element.getAttribute(“ style”)忽略冒号“:”字符之后的所有内容? 仅返回部分值 - Why does element.getAttribute(“style”) ignore everything after the colon “:” character? Returning part of the value only element.onclick返回null,element.getAttribute('onclick')不返回 - element.onclick returns null and element.getAttribute('onclick') does not Element.value 和 Element.getAttribute("value") 的区别 - Difference between Element.value and Element.getAttribute("value") 当属性具有值时element.getAttribute()返回null - element.getAttribute() returns null when attribute has value getAttribute isPermaLink 使用量角器为 rss 提要中的元素返回 null - getAttribute isPermaLink is returning null for element in rss feed with Protractor 承诺待定,promisestatus =已解决? - Promise pending, promisestatus=resolved?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM