Selenium webdriver 在量角器中按承诺使用柴

Selenium webdriver 在量角器中按承诺使用柴,selenium-webdriver,promise,protractor,chai,Selenium Webdriver,Promise,Protractor,Chai,下面我可以让测试使用expect语法,但不使用should语法 以下工作: var expect = chai.expect; describe('expect syntax', function() { it('should work', function() { ... expect(promise).to.eventually.eql('something'); }); }); 但这并不是: chai.should(); describe(

下面我可以让测试使用expect语法,但不使用should语法

以下工作:

var expect = chai.expect;
describe('expect syntax', function() {
    it('should work', function() {
        ...
        expect(promise).to.eventually.eql('something');
    });
});
但这并不是:

chai.should();
describe('should syntax', function() {
    it('should work', function() {
        ...
        (true).should.be.true;
        promise.should.eventually.eql('something');
    });
});
由于我得到以下错误:
TypeError:cannotreadproperty'finally'of undefined
我假设它应该做扩展对象原型的常规工作,但这不适用于webdriver promise对象。这里出了什么问题?

这对我们很有用

  var element = $('#mainDiv');      
  expect(element.isEnabled()).to.eventually.to.equal(true, "Expect Button to be enabled.");
我会确保“承诺”是一个真正的承诺,eql有效吗?我一直使用equal

另一方面,我们按照承诺使用Cucumber与Chai&Chai,但这与承诺无关。

接下来,我不知怎么错过了这一点,问题的根源似乎是WebDriverJ的承诺基于承诺/a和承诺/B,而Chai预期的是承诺/a+类型的承诺

将WebRiverJS承诺包装成Q承诺解决了问题:


Q(webdriverjspromise).should.finally.eql('something')

正如我提到的,expect语法工作正常。但是,should语法似乎与webdriver的承诺不起作用。谢谢。我为此绞尽脑汁了好几个小时!