'Puppeteer Click on Input with type of Checkbox

I have this element I am trying to click on

<input aria-checked="false" type="checkbox" data-reach-custom-checkbox-input="">

I am trying to do something like this but cannot seem to figure it out:

  const [check] = await page.$x('input[type="checkbox"]')
  if(check) {
    console.log("we have a check")
    check.click();
  }

Anyone have any advice on what to do? I can click on buttons in a similar fashion. Here is an example of a working button:

  const [button] = await page.$x("//button[contains(., 'Import')]");
  if (button) {
    await button.click();
  }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source