Path: blob/develop/web/test/e2e/custom-assertions/elementCount.js
387 views
// A custom Nightwatch assertion.1// The assertion name is the filename.2// Example usage:3//4// browser.assert.elementCount(selector, count)5//6// For more information on custom assertions see:7// http://nightwatchjs.org/guide#writing-custom-assertions89exports.assertion = function (selector, count) {10this.message = 'Testing if element <' + selector + '> has count: ' + count11this.expected = count12this.pass = function (val) {13return val === this.expected14}15this.value = function (res) {16return res.value17}18this.command = function (cb) {19var self = this20return this.api.execute(function (selector) {21return document.querySelectorAll(selector).length22}, [selector], function (res) {23cb.call(self, res)24})25}26}272829