title: NoAlertPresentException Error when trying to handle popup Selenium Python
body: <p>I'm attempting to accept a popup on the Facebook website (before being logged in), asking me whether I accept the cookies or not (see image below). However, I keep getting the Exception saying there's no popup/alert on the page and I'm not sure why.</p>
  <p><a href="https://i.stack.imgur.com/iyTSc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iyTSc.png" alt="enter image description here" /></a></p>
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  import time
  
  url = &quot;https://www.facebook.com/&quot;
  browser = webdriver.Firefox()
  browser.get(url)
  
  obj = browser.switch_to_alert()
  obj.accept()
  </code></pre>
  <p>Gives me the following error:</p>
  <pre><code>obj = browser.switch_to_alert()
  
  selenium.common.exceptions.NoAlertPresentException: Message:
  </code></pre>
  <p>I've also tried using time.sleep(5) to let the popup appear but get the same result.</p>