Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

27 righe
765 B

  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. }