Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Stabilize 'I should see no "{elementName}"' e2e step
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Aug 22, 2017
1 parent c650d1f commit 9b48ca9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 6 additions & 3 deletions features/step_definitions/generic.step.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const {
waitForElemAndCheckItsText,
waitForElemRemoved,
waitForElemAndClickIt,
waitForElemAndSendKeys,
checkAlertDialog,
Expand Down Expand Up @@ -77,9 +78,11 @@ defineSupportCode(({ Given, When, Then, setDefaultTimeout }) => {
});

Then('I should see no "{elementName}"', (elementName, callback) => {
browser.sleep(1000);
expect(element.all(by.css(`.${elementName.replace(/ /g, '-')}`)).count()).to.eventually.equal(0)
.and.notify(callback);
const selector = `.${elementName.replace(/ /g, '-')}`;
waitForElemRemoved(selector, () => {
expect(element.all(by.css(selector)).count()).to.eventually.equal(0)
.and.notify(callback);
});
});

Then('I should see "{text}" error message', (text, callback) => {
Expand Down
7 changes: 7 additions & 0 deletions features/support/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ function waitForElemAndCheckItsText(selector, text, callback) {
.and.notify(callback || (() => {}));
}

function waitForElemRemoved(selector, callback) {
const elem = element(by.css(selector));
browser.wait(EC.not(EC.presenceOf(elem)), waitTime,
`waiting for element '${selector}' not present`).then(callback || (() => {}));
}

function waitForElemAndClickIt(selector, callback) {
const elem = element(by.css(selector));
browser.wait(EC.presenceOf(elem), waitTime, `waiting for element '${selector}'`);
Expand All @@ -39,6 +45,7 @@ function checkAlertDialog(title, text, callback) {

module.exports = {
waitForElemAndCheckItsText,
waitForElemRemoved,
waitForElemAndClickIt,
waitForElemAndSendKeys,
checkAlertDialog,
Expand Down

0 comments on commit 9b48ca9

Please sign in to comment.