簡體   English   中英

Element.getAttribute() 將 promisestatus 返回為待處理:protractor

[英]Element.getAttribute() returning promisestatus as Pending : protractor

我的聲明

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);

我的 Output

Rowid 內的全局變量:null 數據內的全局變量:ManagedPromise::19682 {[[PromiseStatus]]: "pending"}

有人可以幫忙嗎

啊,抱歉,沒有注意到protractor標簽。

所以,如果我們有一個承諾的getAttribute ,那么這就是你使用承諾的方式:

elmnt.getAttribute('row-id').then(function(rowId) {
    console.log(rowId);
}); 

您需要在 promise 鏈中執行此操作。 console.log(somePromise)只會記錄一個 promise,而不是一個值, console.log(rowid)在 promise 被解析之前會產生null / undefined

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM