【发布时间】:2015-08-17 20:37:47
【问题描述】:
如何在 SpookyJS 中使用鼠标? 在 CasperJS 中我可以使用鼠标:
var casper = require('casper').create();
var mouse = require("mouse").create(casper);
如何使用 SpookyJS 做到这一点?
【问题讨论】:
-
this.mouse可能在 casper 上下文中?
如何在 SpookyJS 中使用鼠标? 在 CasperJS 中我可以使用鼠标:
var casper = require('casper').create();
var mouse = require("mouse").create(casper);
如何使用 SpookyJS 做到这一点?
【问题讨论】:
this.mouse 可能在 casper 上下文中?
要访问其模块中的任何 Casper 原型,包括其他 CasperJS 模块,您必须在 CasperJS 范围内进行。
如https://github.com/SpookyJS/SpookyJS/wiki/Introduction 中所述:
//this is nodejs environement
//declare your spooky instance here
spooky.start('http://example.com/the-page.html');
spooky.then(function () {
// this function runs in Casper's environment
//here you can access to mouse module. Example :
this.mouse.click(400, 300);
});
spooky.thenEvaluate(function () {
// this function runs in the page's environment
})
// this function (and the three spooky calls above) runs in Spooky's environment
spooky.run();
【讨论】: