木偶“错误:评估失败:TypeError:无法读取null的属性'click'”

时间:2020-02-11 14:51:52

标签: javascript testing puppeteer

我从此函数的标题中得到了错误:

  it('should change comment status to SOLVED',
    async function() {
      await page.click("#view_replies3");
      await change_comment_status(page, 5, 'SOLVED');
  }).timeout(0);

调试之后,我发现问题出在函数“ change_comment_status()”中:

async function change_comment_status(page, comment_id, status) {
  const selector = "input.custom-control-input[name='" +
    comment_id.toString() + "']";
  page.waitForSelector(selector);

  await page.evaluate(selector => {
    let element = document.querySelector(selector);
    element.click();
  }, selector);
}

调用后变量'element'为空

谢谢,伙计们!

0 个答案:

没有答案