【问题标题】:Node js Use puppeteer synchronouslyNode js 同步使用 puppeteer
【发布时间】:2022-06-14 16:27:44
【问题描述】:

您好,我正在尝试同步使用 puppeteer,但是当我尝试访问页面上的 click 方法时出现错误:

let _browser;
let _page;

    puppeteer
      .launch({ headless: false, defaultViewport: null })
      .then((browser) => (_browser = browser))
      .then((browser) => (_page = browser.newPage()))
      .then((page) => page.goto('https://instagram.com'))
      .then(() => _page)
      .then((page) =>  page.waitForTimeout(3000))
      .then((page) => page.click('button[class="aOOlW   HoLwm "]'))
      .then(() => _browser.close());

点击按钮时出现错误 (.then((page) => page.click('button[class="aOOlW HoLwm "]'))):

file:/index.js:38 .then((page) => page.click('button[class="aOOlW
霍勒姆"]')) ^

TypeError:无法读取未定义的属性(读取“点击”) 在文件::/index.js:38:24

有没有办法同步访问页面的点击方法?为什么会出现这个错误?

【问题讨论】:

  • page.waitForTimeout(3000) 返回什么?

标签: javascript node.js synchronization puppeteer


猜你喜欢
  • 1970-01-01
  • 2017-12-09
  • 2015-01-06
  • 1970-01-01
  • 2014-08-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-29
相关资源
最近更新 更多