木偶错误没有为选择器找到节点

时间:2019-01-15 00:17:33

标签: javascript node.js puppeteer

我在使HTML动态页面上的选择器无法动态加载时遇到麻烦。我可以在本地Windows / Centos 7发行版上运行该应用程序,但是当我在Centos 7 Droplet上尝试时,会发生此错误。

Error: No node found for selector: .gcw-origin at assert (bin/glocities-app/node_modules/puppeteer/lib/helper.js:278:11) at Frame.type (bin/glocities-app/node_modules/puppeteer/lib/FrameManager.js:803:5) at <anonymous> at process._tickCallback (internal/process/next_tick.js:189:7) -- ASYNC -- at Frame.<anonymous> (bin/glocities-app/node_modules/puppeteer/lib/helper.js:144:27) at Page.type (bin/glocities-app/node_modules/puppeteer/lib/Page.js:1012:29) at getFlightData (bin/glocities-app/app.js:119:16) at <anonymous> at process._tickCallback (internal/process/next_tick.js:189:7)

这是我的一些代码:

`const delay = ms => new Promise(res => setTimeout(res, ms));

await page.goto("https://www.expedia.com/flights");

await delay(20000);

await page.waitForSelector(".legal");

console.log("Legal Loaded");

console.log("Origin Loaded");

await page.type(".gcw-origin", orig.toString(), { delay: 100 });//Orig is your origin`

1 个答案:

答案 0 :(得分:0)

很长一段时间后,我遇到了像您一样的问题来解决此错误,我在make之前添加了此代码 选择器进行活动:

await page.waitFor("#yourSelector");

它有效。希望它能解决您的问题