title: Selenium Chromedriver - Click Cancel Chrome Authentication Pop Up
body: <p>I'm using a VPN Chrome app for a python application. Whenever I start up a Chrome instance and Chrome starts to load a website before the VPN addon is ready, the following pop-up appears. As soon as I hit the cancel button, the VPN addon is usually ready and I can access the internet without issues. </p>
  
  <p>I'm looking for a way to click the Cancel button with Selenium.</p>
  
  <p>What I have tried so far:</p>
  
  <ul>
  <li><p>Set the home page to Chrome Settings -> pop-up doesn't appear because settings are not a website, after a short time.sleep, I can proceed without issues most of the time. Every once in a while, the pop-up still appears.</p></li>
  <li><p>Using <code>webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform()</code>
  Whenever I try this, the script freezes, until I hit the Cancel button manually, then the action is executed. The same happens with <code>driver.get(url)</code>and <code>driver.switch_to.alert()</code></p></li>
  </ul>
  
  <p>Thanks!</p>
  
  <p><a href="https://i.stack.imgur.com/7e3TP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7e3TP.jpg" alt="Screenshot"></a></p>
  
  <p>Edit 1 (Setting Chrome options to not show notifications and infobars doesn't resolve the issue):</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.chrome.options import Options
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  import selenium.common.exceptions
  
  options = Options()
  options.headless = False
  
  options.add_argument("user-data-dir=ChromeProfiles\Profile_{}".format(22))
  options.add_argument("--profile-directory=profile_1")
  options.add_argument("--disable-notifications")
  options.add_argument("--disable-infobars")
  
  driver = webdriver.Chrome(options=options, executable_path="chromedriver.exe")
  </code></pre>
  
  <p>As you can see, commands are not executed as long as the popup is open:</p>
  
  <p><a href="https://i.stack.imgur.com/n8ciB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n8ciB.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/yZWE8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yZWE8.png" alt="enter image description here"></a></p>