NightmareJS嵌套命令

时间:2017-10-01 22:02:09

标签: javascript node.js nightmare

我无法弄清楚如何为Nightmare做嵌套命令。请考虑以下代码:

let userLinks = await nightmare.evaluate(function(users, nightmare) {
    for(var i = 0; i < users.length; i++) {
        var matchResult = users[i].match(/.com\/(.*?)\?fref/);
        if (matchResult) {
            var newLink = document.createElement('a');
            document.body.appendChild(newLink);
            newLink.setAttribute('href', 'https://www.example.com/'+matchResult[1]);
            nightmare.click('a[href="https://www.example.com/'+matchResult[1]+'"]'); // this won't work
        }
    }
    return null;
}, users);

nightmare.click()赢了。我得到nightmare.click is not a function。怎么办呢?

0 个答案:

没有答案