How to write a nightwatch custom command using jquery
私はこれが機能するために私のアプリのグローバルスコープでのjQueryを利用可能にする必要があります。 (そう私はあなたがちょうどあなたのpackage.json
に依存関係としてjqueryのパッケージを追加すると、あなたは、ファイル内jquery
を必要としなければならない必要があります。通常は、あなたが希望... $(セレクタ)参照文献とのトラブルに
'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;
重複した質問の回答を参照してください。 https://stackoverflow.com/questions/21674080/how-to-use-npm-jquery-module – erwin