I am trying to use jQuery selectors with my Nightwatch.js e2e tests According to this answer :
How to write a nightwatch custom command using jquery
I need to have jQuery available in the global scope of my app for this to work. ( otherwise I got into trouble with $(selector) refs ...
'use strict';
var ClickElementByIndex = function(className, index) {
if (!index) {
index = 0;
}
this.execute(function(selector, i) {
var $item = $(selector + ':eq(' + i + ')');
if (!!$item) {
$item.click();
return true;
}
return false;
}, [className, index], function(result) {
console.info(result);
});
};
exports.command = ClickElementByIndex;