title: How can I use waitforxpath conditionally?
body: <p>There is a button appears sometimes and sometimes it does not.</p>
  
  <p>In case it appears, I should click on it, but in case it does not, I should just continue with the next steps.</p>
  
  <p>This is the code I was using, it doesn't work because, if the button does not appear, a timeout happens.</p>
  
  <pre><code> const continueASButton = await page.waitForXPath(
      "//button[contains(@name, '__CONFIRM__')]"
    );
  
    await continueASButton.click();
  </code></pre>
  
  <p>I also tried this, but it seems like its not valid code.</p>
  
  <pre><code>if (
      (await page.waitForXPath("//button[contains(@name, '__CONFIRM__')]")) !==
      null
    ) {
      (
        await page.waitForXPath("//button[contains(@name, '__CONFIRM__')]")
      ).click();
    }
  </code></pre>