Skip to content

Instantly share code, notes, and snippets.

@beatfactor
Created September 30, 2015 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beatfactor/8b49e28947c6a048bc4f to your computer and use it in GitHub Desktop.
Save beatfactor/8b49e28947c6a048bc4f to your computer and use it in GitHub Desktop.
elementEmpty.js
exports.assertion = function(selector) {
this.selector = selector;
this.message = 'Testing if element <' + selector + '> has no descendents.';
this.expected = true;
this.pass = function(value) {
return value && (value.length === 0);
};
this.value = function(result) {
return result && result.value;
};
this.command = function(callback) {
var self = this;
this.api.elements('css selector', this.selector, function(result) {
if (result.status === 0 && result.value.length > 0) {
this.elementIdElements(result.value[0].ELEMENT, 'css selector', '*', function(res) {
callback(res);
});
} else {
self.message += ' No elements were returned for selector: ' + self.selector;
callback(false);
}
});
return this;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment