We added a few helpers to add additional context and reduce boilerplate. They turn failure messages like expected 'bar' to equal 'foo'
into element with selector ".foo-bar": getText: expected 'bar' to equal 'foo'
.
// before
expect(await browser.getUrl()).to.endWith('foo');
// after
await expect(browser).url.to.eventually.endWith('foo');
// before
expect(await browser.getTitle()).to.contain('foo');
// after
await expect(browser).title.to.eventually.contain('foo');
// before
expect(await pageObject.getText()).to.equal('foo');
// after
await expect(pageObject).text.to.eventually.equal('foo');
// before
expect(await pageObject.getValue()).to.equal('foo');
// after
await expect(pageObject).value.to.eventually.equal('foo');
// before
expect(await pageObject.isEnabled()).to.be.ok;
// after
await expect(pageObject).enabled.to.eventually.be.ok;
// before
expect(await pageObject.isDisplayed()).to.be.ok;
// after
await expect(pageObject).displayed.to.eventually.be.ok;
// before
expect(await pageObject.isExisting()).to.be.ok;
// after
await expect(pageObject).exist.to.eventually.be.ok;
// before
expect(await pageObject.getElements()).to.have.a.lengthOf(2);
expect(await pageObject.getElements()).to.have.a.lengthOf.above(1);
expect(await pageObject.getElements()).to.have.a.lengthOf.below(2);
expect(await pageObject.getElements()).to.have.a.lengthOf.at.least(2);
expect(await pageObject.getElements()).to.have.a.lengthOf.at.most(1);
expect(await pageObject.getElements()).to.have.a.lengthOf.within(0, 1);
// after
await expect(pageObject).elements.to.eventually.have.a.lengthOf(2);
await expect(pageObject).elements.to.eventually.have.a.lengthOf.above(1);
await expect(pageObject).elements.to.eventually.have.a.lengthOf.below(2);
await expect(pageObject).elements.to.eventually.have.a.lengthOf.at.least(2);
await expect(pageObject).elements.to.eventually.have.a.lengthOf.at.most(1);
await expect(pageObject).elements.to.eventually.have.a.lengthOf.within(0, 1);