ClientUtils#findAll(字符串选择器)示例代码没有'不起作用

ClientUtils#findAll(String selector) example code doesn't work

本文关键字:不起作用 代码 字符串 选择器 ClientUtils#findAll      更新时间:2023-09-26

此CasperJS代码示例(http://casperjs.org/api.html#clientutils.findAll)不起作用。有人知道怎么让这个东西工作吗?

var links;
casper.start('http://foo.bar/', function() {
    links = this.evaluate(function() {
        var elements = __utils__.findAll('a.menu');
        return Array.prototype.forEach.call(elements, function(e) {
            return e.getAttribute('href');
        });
    });
});
casper.run(function() {
    this.echo(JSON.stringify(links)).exit();
});

使用Array#map而不是Array#forEach