count.js 508 B

123456789101112131415161718
  1. exports.assertion = function (selector, count) {
  2. this.message = 'Testing if element <' + selector + '> has count: ' + count
  3. this.expected = count
  4. this.pass = function (val) {
  5. return val === this.expected
  6. }
  7. this.value = function (res) {
  8. return res.value
  9. }
  10. this.command = function (cb) {
  11. var self = this
  12. return this.api.execute(function (selector) {
  13. return document.querySelectorAll(selector).length
  14. }, [selector], function (res) {
  15. cb.call(self, res)
  16. })
  17. }
  18. }