събота, 13 юни 2015 г.

Cucumber-js and Chai how to expect if element with given selector exist in DOM

This week I had one problem with protractor and cucumberjs. I read protractor documentation and asked question into stackoverflow. I want to share one very small learned lesson here also. If you want to expect if element with a given selector exist in DOM you must use isPresent() it returns a promise that will resolve to whether the element is present on the page.

    element(by.id('someId')).isPresent().then(function(isElementVisible) {
         expect(isElementVisible).to.be.true;   
    });
 
Or use chai with promises.

    expect(element.isPresent()).to.eventually.be.false
 
However, the word "eventually" sounds unpleasant. We want to be sure not eventually sure. :)
Here can be viewed the quesion into stackoverflow.  

Няма коментари:

Публикуване на коментар