Blame view
test/e2e/custom-assertions/elementCount.js
765 Bytes
8a0dd59d9
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
// 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 (selector, count) { this.message = 'Testing if element <' + selector + '> has count: ' + count this.expected = count this.pass = function (val) { return val === this.expected } this.value = function (res) { return res.value } this.command = function (cb) { var self = this return this.api.execute(function (selector) { return document.querySelectorAll(selector).length }, [selector], function (res) { cb.call(self, res) }) } } |