title: Python: Pyppeteer clicking on pop up window
body: <p>I'm trying to accept the cookies consent on a pop up window that is generated on this <a href="https://www.trustarc.com/" rel="noreferrer">page</a>. I tried to use <code>waitForSelector</code> but none of the selectors that I used seems to be visible to the headless browser. I would like to actually switch to "YES" and then submit the form. I guess it's displayed on <code>window.onload</code> so perhaps this will need to be done in JavaScript?</p>
  
  <pre><code>import asyncio
  import time
  
  from pyppeteer import launch
  from pyppeteer.errors import TimeoutError
  from urllib.parse import urlparse
  
  URLS = [
      'https://www.trustarc.com/'
  ]
  
  start = time.time()
  
  async def fetch(url, browser):
      page = await browser.newPage()
      try:
          #await page.setRequestInterception(True)
          page.on('request', callback)
          await page.goto(url, {'waitUntil': 'networkidle0'})
          await page.screenshot({'path': f'img/{urlparse(url)[1]}.png', 'fullPage': True})
      except TimeoutError as e:
          print(f'Timeout for: {url}')
      finally:
          await page.close()
  
  
  async def callback(req): 
      print(f'Request: {req.url}')
  
  async def run():
      browser = await launch(headless=True, args=['--no-sandbox'])
      tasks = []
  
      for url in URLS:
          task = asyncio.ensure_future(fetch(url, browser))
          tasks.append(task)
  
      ret = await asyncio.gather(*tasks)
      await browser.close()
  
  loop = asyncio.get_event_loop()
  future = asyncio.ensure_future(run())
  loop.run_until_complete(future)
  
  print(f'It took {time.time()-start} seconds.')
  </code></pre>