title: Puppeteer - Check if xPath element is visible
body: <p>Hi I'm trying to check if an element on the page is visible or not.</p>
  <p>Firstly I would like to say that I'm aware of the solution here:</p>
  <pre><code>async function isVisible(page, selector) {
    return await page.evaluate((selector) =&gt; {
      var e = document.querySelector(selector);
      if (e) {
        var style = window.getComputedStyle(e);
  
        return style &amp;&amp; style.display !== 'none' &amp;&amp; style.visibility !== 'hidden' &amp;&amp; style.opacity !== '0';
      }
      else {
        return false;
      }
    }, selector);
  }
  </code></pre>
  <p>However this does not work with xPaths.</p>
  <p>Is there a solution to return a <code>true</code> or <code>false</code> about an elements visibility using xPath?</p>
  <p>I'm thinking of something like this</p>
  <pre><code>async function isVisible(page, xPathSelector){}
  
  //Returns true or false
  await isVisible(page, &quot;//button[type='button' and text() = 'Click Me']&quot;);
  </code></pre>
  <p>Thanks!</p>