如何在SpookyJS中使用鼠标



如何在SpookyJS中使用鼠标?在CasperJS中,我可以使用鼠标:

var casper = require('casper').create();
var mouse = require("mouse").create(casper);

我怎么能做到与SpookyJS?

要访问其模块中的任何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();

最新更新