【发布时间】:2023-12-31 14:04:01
【问题描述】:
我正在尝试遍历通过 Nightmare.js 获得的 NodeList。在开发工具中执行按预期执行,但在 Electron 中我无法成功将 NodeList 转换为数组。
nightmare
.goto('https://www.somePage.com')
.wait('#someID')
.evaluate(function () {
var links = document.querySelectorAll('div.someClass')
return links;
})
.end()
.then(function (result) {
console.log(result); // outputs the NodeList successfully.
var nodesArray = Array.prototype.slice.call(result);
console.log(nodesArray.length) // Always 0
})
.catch(function (error) {
console.error('Failed',
error);
})
我已经尝试通过各种其他方法移植 NodeList。在 Electron 中没有什么可以工作的。同样,这在 chrome 工具中很容易实现。
【问题讨论】:
标签: node.js electron nightmare nodelist