I have a problem with cucumbers. I cannot find a way to provide this element with the given selector presented in the DOM. I use cucumbers with tea. https://github.com/cucumber/cucumber-js isPresent returns an object - whether this element exists or not. So the question is how to check if an element is present in the DOM.
I will edit the question to share one lesson learned. I read the documentation and I want to thank Nathan Thompson. present () returns a promise that will decide if an element is present on the page.
http://angular.imtqy.com/protractor/#/api?view=Protractor.prototype.isElementPresent
The code examples are a bit misleading. Therefore, if you want to expect that an element with this selector exists in the DOM, you should 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 โin the endโ sounds unpleasant. We want to be sure that in the end we are not sure. :)
Here you can view an article about this issue in my personal blog.
javascript protractor cucumberjs chai
Georgi Naumov
source share