title: How do I search a page for a specific URL and click on it using Puppeteer?
body: <p>I've spent the last few days trying to figure out how to use Puppeteer to search a page for links that contain a particular word, and then click on the first one.</p>
  
  <p>The page's HTML contains a number of links such as: </p>
  
  <p><code>&lt;a href="https://www.example.com/home"&gt;Example - Home&lt;/a&gt;</code></p>
  
  <p><code>&lt;a href="https://www.example.com/about"&gt;Example - About&lt;/a&gt;</code></p>
  
  <p><code>&lt;a href="https://www.example.com/contact"&gt;Example - Contact&lt;/a&gt;</code></p>
  
  <p>and I'd like for it to find the first url with the words "example.com" in it, and click on that link. If there are no such URLs on that page, I'd like it to then click on another button.</p>
  
  <p>I'm not particularly familiar with Javascript and feel like I've tried a number of different variations of using <code>document.querySelector</code> and <code>document.querySelectorAll</code> (and the Puppeteer version of these - i.e. <code>page.$</code> and <code>page.$$</code>), but none of which fully work.</p>
  
  <p>I'd be super grateful if anyone can point me in the right direction!</p>