title: Selenium doesn't load page when running chrome headless - python - alert or pop up error
body: <p>(irrelevant background info: my laptop was stolen, I'm making this so if it were to ever happen again, I'd have a decent chance of recovering it)</p>
  
  <p>THE PROBLEM:</p>
  
  <p>So I'm trying to get a python script running which will (secretly) screenshot the current geolocation as per this website:
  <a href="https://gps-coordinates.org/my-location.php" rel="nofollow noreferrer">https://gps-coordinates.org/my-location.php</a></p>
  
  <p>It works great without the headless option, but with it, the location just isn't loading. My suspicion is headless mode doesn't allow popups or alerts properly and as such chrome is not able to "remember" my choice to always allow location.</p>
  
  <p>I've looked at the source code and the location information comes up under the class "leaflet-popup-content"</p>
  
  <p>WHAT I'VE TRIED:</p>
  
  <p>I've already tried using the wait for element present </p>
  
  <p>as below:</p>
  
  <pre class="lang-py prettyprint-override"><code>def waitForLoad(browser):
      try:
          WebDriverWait(browser, 10, ignored_exceptions=[
              NoSuchElementException, TimeoutException
          ]).until(EC.presence_of_element_located((By.CLASS_NAME,'leaflet-popup-content')))
      except TimeoutException:
          print("Error, timed out, trying again")
          browser.refresh()
          waitForLoad(browser)
          return
  </code></pre>
  
  <p>I've also tried this with the firefox driver (geckodriver), but it's not even working before headless is set</p>
  
  <p>THE CODE:</p>
  
  <pre class="lang-py prettyprint-override"><code>import selenium
  from selenium import webdriver
  from selenium.webdriver.chrome.options import Options
  
  chrome_options = Options()
  chrome_options.add_argument("--headless")
  chrome_options.add_argument("--disable-infobars")
  browser=webdriver.Chrome('/home/tclack/bin/chromedriver',chrome_options=chrome_options)
  # YMMV this is the chromedriver I use and the location
  
  url = "https://gps-coordinates.org/my-location.php"
  
  browser.get(url)
  
  browser.save_screenshot('screenshot.png')
  browser.close()
  browser.quit()
  </code></pre>
  
  <p>Expected output is a .png file with the current location selected as you would see if you ran this but commented out the "--headless" line (line 6). (also assuming this website is "whitelisted" in terms of allowing location)</p>