title: UnhandledPromiseRejectionWarning: error throwing inside of an async function without a catch block, promise which was not handled with .catch()
body: <p>I hope you can help me, I have been using node.js for a short time and only a week with puppeteer and I have made a small excrip to automate a task, when running the script it performs the process correctly at a glance.</p>
  <hr />
  <p>However, the console throws me two types of errors:</p>
  <p>1st - UnhandledPromiseRejectionWarning: TimeoutError: waiting for selector <code>.flexMain&gt; div&gt; div&gt; #PageContent_AuthorisedButtons&gt; .btn</code> failed: timeout 30000ms exceeded
  at new WaitTask</p>
  <p>2nd - 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 ().</p>
  <hr />
  <p>I would appreciate help to solve the problem since I have been stuck and do not see the solution.</p>
  <hr />
  <pre><code>const puppeteer = require('puppeteer');
  
  (async () =&gt; {
      try {
  
          const browser = await puppeteer.launch({
              headless: false,
              userDataDir: &quot;./cache&quot;,
              ignoreDefaultArgs: [
                  &quot;--disable-extensions&quot;,
                  &quot;--enable-automation&quot;
              ],
              args: [
                  &quot;--no-sanbox&quot;,
                  &quot;--disable-setuid-sandbox&quot;,
                  &quot;--disable-dev-shm-usage&quot;,
                  &quot;--disable-gpu&quot;
              ]
          })
  
          const page = await browser.newPage();
          page.setRequestInterception(true);
          page.on(&quot;request&quot;, async req =&gt; {
              if (req.url().endsWith(&quot;.png&quot;)) {
                  req.abort();
              } else {
                  req.continue();
                  
                  await page.waitForSelector('.flexMain &gt; div &gt; div &gt; #PageContent_AuthorisedButtons &gt; .btn');
                  await page.click('.flexMain &gt; div &gt; div &gt; #PageContent_AuthorisedButtons &gt; .btn');
              }
  
  
          });
  
  
  
          page.on('error', e =&gt; console.log(e));
  
          await page.goto('http://example.com');
  
          await page.setViewport({ width: 1920, height: 926 });
  
          await page.waitForSelector('.flexMain &gt; div &gt; div &gt; #PageContent_UnauthorisedButtons &gt; .btn');
          await page.click('.flexMain &gt; div &gt; div &gt; #PageContent_UnauthorisedButtons &gt; .btn');
  
          await page.type('.row #SignInEmailInput', 'example@gmail.com');
  
          await page.waitForSelector('.col-md-7 &gt; #SignInForm &gt; .form-group &gt; div:nth-child(2) &gt; a');
          await page.click('.col-md-7 &gt; #SignInForm &gt; .form-group &gt; div:nth-child(2) &gt; a');
  
          const collectCaptcha = await page.$('#adcopy-puzzle-image-image');
          collectCaptcha.screenshot({ path: 'src/img/capture-captcha.png' });
  
          const urlImageCaptcha = path.join(__dirname, 'img/capture-captcha1.png');
  
          // page.waitForTimeout(10000)
  
  
          // await browser.close()
  
      }
      catch (e) {
  
      }
  
  })()
  </code></pre>