I have a problem with cucumberjs. I cannot find a way to ensure that element with given selector is presented into DOM. I'm using cucumberjs with Chai. https://github.com/cucumber/cucumber-js isPresent returns object - no matter if the element exists or not. So the question is how to check if element is present in DOM.
I will edit the question to share one learned lesson. I read the documentation also want to thanks to Nathan Thompson. isPresent() returns a promise that will resolve to whether the element is present on the page.
http://angular.github.io/protractor/#/api?view=Protractor.prototype.isElementPresent
The code examples is a little misleading. So if you want to expect if element with a given selector exist in DOM you must use something like this:
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 article about this question into my personal blog.