1

是否可以让 casperjs 单击特定的 x、y 位置?我基本上是在尝试与画布交互(单击画布上的特定点),但不知道如何去做。如果不可能,是否有可以做到这一点的前端库?

谢谢

4

2 回答 2

1

尝试访问 Phantom api:

casper.then(function() { 
    this.page.sendEvent(...)
}); 
于 2013-08-14T20:47:25.413 回答
0

CasperJS 提供了一个mouse模块,您可以使用它来放置mouse.click某个地方。

我建议先检索画布区域,然后相对于画布元素放置单击。您甚至可以拥有自己的功能:

casper.relativeClick = function(selector, x, y){
    var info = this.getElementInfo(selector);
    if (x < info.width && y < info.height) {
        x += info.x;
        y += info.y;
        this.mouse.click(x, y);
    } else {
        console.log("warning: click out of bounds");
    }
}

then*然后,您可以在步骤 (或wait*) 中调用它。

于 2014-07-08T16:21:14.873 回答