Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142188

Puppeteer "Error: Evaluation failed: TypeError: Cannot read property 'click' of null"

$
0
0

I'm getting the error from the title for this function:

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

After debugging I have figured out that the problem is in the function "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);
}

the variable 'element' is null after the call

Thanks, guys!


Viewing all articles
Browse latest Browse all 142188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>