Javascript 迁移到Cucumber 4时,我如何回报承诺?

Javascript 迁移到Cucumber 4时,我如何回报承诺?,javascript,protractor,cucumberjs,Javascript,Protractor,Cucumberjs,我正在将测试用例迁移到Cucumber4,我有以下代码片段,我想在Cucumber4类型的代码中转换 主页.js this.isHomeButtonEnabled = function(){ var isButtonEnabled = true; browser.element(by.css('.home-btn')).getAttribute('disabled').then(function () { isButtonEnabled = false; })

我正在将测试用例迁移到Cucumber4,我有以下代码片段,我想在Cucumber4类型的代码中转换

主页.js

this.isHomeButtonEnabled = function(){
  var isButtonEnabled = true;
   browser.element(by.css('.home-btn')).getAttribute('disabled').then(function () {
         isButtonEnabled = false;
   })
   return isButtonEnabled;
}
我的预期情景是

expect(homePage.isHomeButtonEnabled()).to.be(true);
现在我上面的功能,即isHomeButtonEnabled应该返回承诺。但迁移上述代码段的合适方法是什么

选项1使用量角器启用api:

选项2使用getAttribute“禁用”:

this.isHomeButtonEnabled = function(){
   return element(by.css('.home-btn')).isEnabled();
}
this.isHomeButtonEnabled = function(){
   return element(by.css('.home-btn')).getAttribute('disabled')
         .then(function(disabled){
             return disabled === null ? true: false;
          });
}