view client/tests/e2e/custom-assertions/elementCount.js @ 662:d856e458dd64 octree

Added snappy to 3rd party libs.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 18 Sep 2018 00:13:51 +0200
parents 7c40e9f28f94
children 0c5cbbafbd94
line wrap: on
line source

// A custom Nightwatch assertion.
// The assertion name is the filename.
// Example usage:
//
//   browser.assert.elementCount(selector, count)
//
// For more information on custom assertions see:
// http://nightwatchjs.org/guide#writing-custom-assertions

exports.assertion = function elementCount(selector, count) {
  this.message = `Testing if element <${selector}> has count: ${count}`;
  this.expected = count;
  this.pass = val => val === count;
  this.value = res => res.value;
  function evaluator(_selector) {
    return document.querySelectorAll(_selector).length;
  }
  this.command = cb => this.api.execute(evaluator, [selector], cb);
};