title: How to click a button by name or text with puppeteer?
body: <p>I am new to puppeteer and stuck in trying to click a certain button on yahoo. I face the following situation:</p>
  
  <p><a href="https://i.stack.imgur.com/j4DT4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/j4DT4.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/64UMn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/64UMn.png" alt="enter image description here"></a></p>
  
  <p>I tried to select click on the button as follows:</p>
  
  <pre><code>const [button] = await page.$x("//button[contains(., 'OK')]");
  if (button) {
     await button.click();
  }
  </code></pre>
  
  <p>Unfortunately without success.
  How would I click on the OK button in general? And what would be a solution to check whether the button exists or not. Thank you very much for your help.</p>