You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 rivejä
765 B

3 vuotta sitten
  1. // A custom Nightwatch assertion.
  2. // The assertion name is the filename.
  3. // Example usage:
  4. //
  5. // browser.assert.elementCount(selector, count)
  6. //
  7. // For more information on custom assertions see:
  8. // http://nightwatchjs.org/guide#writing-custom-assertions
  9. exports.assertion = function (selector, count) {
  10. this.message = 'Testing if element <' + selector + '> has count: ' + count
  11. this.expected = count
  12. this.pass = function (val) {
  13. return val === this.expected
  14. }
  15. this.value = function (res) {
  16. return res.value
  17. }
  18. this.command = function (cb) {
  19. var self = this
  20. return this.api.execute(function (selector) {
  21. return document.querySelectorAll(selector).length
  22. }, [selector], function (res) {
  23. cb.call(self, res)
  24. })
  25. }
  26. }