【问题标题】:How to use mouse in SpookyJS?如何在 SpookyJS 中使用鼠标?
【发布时间】:2015-08-17 20:37:47
【问题描述】:

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

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

如何使用 SpookyJS 做到这一点?

【问题讨论】:

  • this.mouse 可能在 casper 上下文中?

标签: node.js casperjs spookyjs


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多