函数调用:
var oldBalance = objToPageObjectFile.getBalance();
//objToPageObjectFile is object referring to a file where "getBalance()" is defined.
功能定义:
Works with ".then()"
this.getBalance=function()
{
var storeBalance = readBalance.getText().then(function(balance){
return balance;
});
return storeBalance;
}
不适用于异步/等待
this.getBalance() = async function()
{
var storeBalance;
storeBalance = await readBalance.getText();
return storeBalance;
}
错误是: 错误:TypeError:this.getBalance不是函数
为什么我的异步/等待错误?我正在使用InteliJ IDE。
答案 0 :(得分:0)
问题可能是getBalance
之后的括号,请尝试以下操作:
this.getBalance = async () => {
// Your code goes here
}
更新
编辑了代码,以重点解决问题中的错误。