title: How to handle waitForSelector when selector is not found
body: <p>I'm trying to wait for a selector. When the selector is not available, which can happen I would expect to catch that error in the .catch() and be able to proceed with my program. Instead I get the <code>UnhandledPromiseRejectionWarning</code> error.</p>
  <p>How can I write a program that can handle selectors that is not found or times out?</p>
  <p><strong>Code</strong></p>
  <pre><code>await page.waitForSelector('#step3 &gt; div &gt; div &gt; div &gt; div.time-selection-wrapper &gt; div.v-card.v-sheet.theme--light &gt; div &gt; div &gt; div.v-picker__title.primary-color &gt; div &gt; div.v-picker__title__btn.v-date-picker-title_custom1.v-picker__title__btn--active &gt; div', {timeout: 5000})
      .then(async () =&gt; {
          console.log(&quot;Entered THEN&quot;)
      })
      .catch((e) =&gt; {
          if (e instanceof puppeteer.errors.TimeoutError) {
              console.log(&quot;Timeout&quot;)
          }
      })
  </code></pre>
  <p><strong>Output</strong></p>
  <blockquote>
  <p>Timeout
  (node:9540) UnhandledPromiseRejectionWarning: Error: Node is either not clickable or not an HTMLElement
  at ElementHandle.clickablePoint (/home/john/git/myproject/node_modules/puppeteer/lib/cjs/puppeteer/common/JSHandle.js:412:19)
  (node:9540) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  (node:9540) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.</p>
  </blockquote>
  <pre><code></code></pre>