我想用夜班做一些自动测试:
this.demoTest = function (browser) {
browser.executeAsync(function(data, done) {
someAsyncOperation(function() {
done(true);
});
}, [imagedata], function(result) {
// ...
});
};
但我不知道如何使用executeAsync,flow是我的代码:
module.exports = {
'Demo asynchronous' : function(client){
client.url(client.launchUrl);
client.executeAsync(function(data, done) {
someAsyncOperation(function() {
client.setValue('#PoiSearch', data);
client.click('#POISearchButton');
done(true);
});
}, ['hotle'], function(result) {
client.expect.element('#Map div[name*="mark"]').to.be.present;
});
}
}
我只想输入一个单词,而不是单击搜索按钮,因此我想知道DOM有特殊元素。但我不知道如何使用executeAsync。
答案 0 :(得分:2)
您传递给jQuery(document).ready(function(){
jQuery(document).on('click', '.rowclass', function(e) {
var link = $(this).find("a");
if (e.target === link[0]) return false;
link.trigger('click');
return false;
});
})
的函数将被执行,就像它在您控制的浏览器的javascript控制台中一样(其他所有内容都在节点/ selenium上下文中执行。因此,您不会可以访问executeAsync
函数内的client
变量。
如果您想等待使用nightwatch API填充这些字段,您可以执行以下操作:
```
executeAsync
```